My answer to your #4 would be "no". To me, curly brackets are part of the conditional or looping construct.
And I personally don't find it helpful to have open and close curlies line up vertically. I find it very annoying to scroll to some point in a file and see something like
{
...do something...
.
.
}
Huh? Is that part of an if, while, for, or ? Oh, right. The important part is just above the top of the screen. I'd much rather have the close curly line up with the keyword.
But, as many others have pointed out, that's all a matter of religion1. So to actually add something useful to this topic, I'll assert that everyone should try out a couple of different styles. And not just for a file or two. Personally, I have to stick to a style for about a month to get through the full set of phases:
- disgust and revulsion
- grudging acceptance and understanding of how the lunatics who use that style are able to make sense and extract value out of it
- enthusiastic and wholesale adoption of the style for yourself, together with disbelief at how mired you were in your ridiculous old style
- (this one usually comes after going back to editing one of your old projects) complete reversal -- wonderment at how you could possibly have found that new style any good. Sure, it has its advantages, but your original style is just so much better.
- and finally: integration, when you merge parts of the old and new together to make something that is more like one than the other, but takes parts from both.
Or perhaps I'm just a slow learner. But the main thing to come out of this is
tolerance. I had a big hang-up for a long time where I just
couldn't work on a project written in a style I found abhorrent. Well, I could, but I would first reformat everything, and the original maintainer would ignore all of my patches because they looked like crap to him. Or, if we were forced to work together (eg on a school project), we would be constantly annoyed at each other, and prone to needlessly rewriting swathes of each other's code just to make them "readable"
2.
After I (unwillingly) went through a couple of those series of phases I listed above, I actually found it very liberating to be able to shift between styles fluidly to match whatever existing code I encountered. There are too many barriers to working with other people's code already: programming language, NIH syndrome, portability, licensing, .... You do not want style to be yet another one.
Open source projects are great for this, since there are undoubtably several out there that interest you for personal reasons, and aren't written in your preferred style.
1 And what's the one thing that all religions have in common? That's right, they all hold that they are right and all the rest are wrong.
2 On the other hand, this helped my typing speed immeasurably. Whoever could type faster would be able to gradually convert the codebase to the One True Style.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.