Brace style
-
I have never written anything significant in Perl.
You're not missing anything. Dreadful language.
Kevin
-
if you left how do you know the code never was changed since then?
-- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
Because I lied, there were some minor changes. I know because I was contracted to make them. One of the reasons I left was because they did not really need a full time coder any more, they just did not know it. They did not hire anyone to take my place and any time there is a question or they need something modified they call me. About the only thing that took more than a couple of hours to do was when a third party control failed to work on XP and I had to write a replacement from scratch (the 3rd party did not exist any more). Now if only they would contract me to produce a modern version of the two main programs I would be a happy camper, because they would not let me do it when I worked there.
INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
-
Which one you prefer ?
if{
//do something
}Or
if
{
//do something
}
printf("Navaneeth!!") www.w3hearts.com
http://astyle.sourceforge.net/[^] because I prefer:
style=ansi indent-namespaces
and one of the senior programmers keeps us from having a style guide by demandingstyle=ansi indent-brackets
Of course there is programmer brawl number #2342: how do you make a header comment (I was told yesterday there is one and only one way). :)_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
-
Which one you prefer ?
if{
//do something
}Or
if
{
//do something
}
printf("Navaneeth!!") www.w3hearts.com
God of course intended that there be only one bracing style. All other expose one as a programmer who has fallen from the path. The pattern for an 'if' is as follows:
if (conditional) { // waste not, want not: don't waste vertical space
statement(s) // note the indention, this clearly identifies these statements as
// belonging to the if
} // note the indention again, this closes the if logic, it is the
// end of the existing block, not the beginning of a new oneOf course heritics abound, but my place in "code vault store" is assured (ya have to be a fan of STTNG Klingon afterlife to get that one). Go forth and spread the glad tiding and good bracings and do not hesitate to cntl-K cntl-D the code of the unbelievers. ;):laugh: Brace Zealot -- modified at 11:16 Thursday 17th May, 2007
-
Which one you prefer ?
if{
//do something
}Or
if
{
//do something
}
printf("Navaneeth!!") www.w3hearts.com
if
{
//lalala
//doing_stuff
}old fashioned i guess
Ericos Georgiades
-
God of course intended that there be only one bracing style. All other expose one as a programmer who has fallen from the path. The pattern for an 'if' is as follows:
if (conditional) { // waste not, want not: don't waste vertical space
statement(s) // note the indention, this clearly identifies these statements as
// belonging to the if
} // note the indention again, this closes the if logic, it is the
// end of the existing block, not the beginning of a new oneOf course heritics abound, but my place in "code vault store" is assured (ya have to be a fan of STTNG Klingon afterlife to get that one). Go forth and spread the glad tiding and good bracings and do not hesitate to cntl-K cntl-D the code of the unbelievers. ;):laugh: Brace Zealot -- modified at 11:16 Thursday 17th May, 2007
grgran wrote:
Of course heritics abound, but my place in "code vault store"
Brandishes steel cored foam cluebat. *BIFFF* *BIFFF* *BIFFF* *BIFFF* *BIFFF* *BIFFF* *BIFFF* *BIFFF*
-- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
-
Pete O`Hanlon wrote:
BTW - my personal preference is braces on a new line
We agree on something then;)
.net is a box of never ending treasures, every day I get find another gem.
I'm even more anal about bracing. I use if(blah) { stuff even if only one line. Notice the indent; } That way I can line up the if, else etc and eyeball for closing braces to see which block the code is in. I find: if(blah) { dgf dfd df df fdf dfdf } else { dfd df df dsf dg } method annoying. You are forced to look at the first character of each line to see if it is the brace your looking for, rather than scan down the column where the brace your looking for should be.
-
I'm even more anal about bracing. I use if(blah) { stuff even if only one line. Notice the indent; } That way I can line up the if, else etc and eyeball for closing braces to see which block the code is in. I find: if(blah) { dgf dfd df df fdf dfdf } else { dfd df df dsf dg } method annoying. You are forced to look at the first character of each line to see if it is the brace your looking for, rather than scan down the column where the brace your looking for should be.
-
Oh crap, I got slaughtered by white space removal. The buggers ;) Corrected
if(blah) { stuff even if one line. Notice the indent. }
-
This is interesting, I myself used the latter, but in the programming course Ive done they teach using the former, although Ive gotten used to programming like that i still dont like it and prefer having the extra line breaks
-
Which one you prefer ?
if{
//do something
}Or
if
{
//do something
}
printf("Navaneeth!!") www.w3hearts.com
Prefer? My preference is irrelevant. The ancients said it best.. when in Rome, do as the Romans. When in someone else's code, match their style. Unless you're writing C#, in which case, Caesar Gates's cronies have decreed how we will all do our braces, spacing and indentation. Fine, whatever, we've all got more important things to do than to fight it anyway.. right? After 20 or so years of reading all different brace styles, you'll pretty much cease to see them anyway.. as long as it is consistent throughout a file. Remember, Rome-Romans. What should you do in completely new files? Sure, fine, whatever. Which do I do in new files? The second one. Why? Because I was asked to. Why was I asked to? I dunno, probably because someone had a harder time of understanding the code with the first one. Why do I bother to comply? Because they claim it helps them.
patbob
-
Which one you prefer ?
if{
//do something
}Or
if
{
//do something
}
printf("Navaneeth!!") www.w3hearts.com
How about letting the development environment decide based on who you are... that way if you like it one way and your colleague likes it formatted another way, you both can have your cake and eat it too.
-
I don't like extra line breaks. I've been reading code for many years and I don't need the visual noise. I like things in a smaller space. I leave out braces for single-statement blocks, and I love the (x ? y : z) notation. It's a non-issue though, because VS can quickly re-format code to your personal style. It takes a bit of fiddling with the options, but you can get whatever you want out of it.
"Quality Software since 1983!"
http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles. -
Which one you prefer ?
if{
//do something
}Or
if
{
//do something
}
printf("Navaneeth!!") www.w3hearts.com
-
My favourite (probably) apocryphal story on this point is that K&R used their style for no other reason that to save space (and thus publishing costs) in their book. I sooo want this to be true. What about this one: if (something) { do_something(); } While we're at it... Tabs or spaces? :-)
-
The latter. The former is used only by miscreants and rogues. :suss:
----
i hope you are feeling sleepy for people not calling you by the same.
--BarnaKol on abusive words
-
Which one you prefer ?
if{
//do something
}Or
if
{
//do something
}
printf("Navaneeth!!") www.w3hearts.com
If you have an ounce of artistry in your soul as a programmer you would use the latter. The first one drives me nuts, it just screams out to me to be dropped down to the latter style. I find the visual style and symmetry of code to be equally important as comments in understanding it and life is to short to play "match the braces" when editing existing code. Every block of code should be indented from it's surrounding block and the opening and closing characters should be on the same column.
"110%" - it's the new 70%
-
Thats crazy, even marking it as code this site doesn't keep your formating. Whoever coded this webform is going to go to scripting hell. Every thing he codes will be parsed and emulated on a Comandor 64, no native code for you:laugh:
The pre tag is what you want. code is only intended for a small snippet of code in the middle of plain text. Yes it is confusing. :mad:
-- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
-
The pre tag is what you want. code is only intended for a small snippet of code in the middle of plain text. Yes it is confusing. :mad:
-- You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
-
Which one you prefer ?
if{
//do something
}Or
if
{
//do something
}
printf("Navaneeth!!") www.w3hearts.com
if (condition) then do something endif -CB :)