K&R or read all of Thantos' posts!
Printable View
K&R or read all of Thantos' posts!
Wel, I use Allman style if it's some long code block, like a whole class or something with a bunch of code, otherwise I use the other one. The one which looks like this:
Code:void SayHi(){
std::cout<< "Hi!" <<std::endl;
}
Gawd! So much freedom given to the C/C++ programmer. How would you feel about coding in Python, where consistent indentation is actually part of the required syntax?
I programmed a while in Python before I started with C and I still find the freedom a little disconcerting. Logically I'm drawn toward the Allman style, which visually seems more suitable for my neurotic mind. I'm the kind of person who can't concentrate if there's a book on the desk that's sitting at an angle. In the local library as a kid I'd walk up and down the shelves making sure every book was pushed back as far as it would go. When I'm walking the dog if I look down and one of his ears is turned inside out it drives me crazy - I have to stop and flip it back over. That kind of thing.
I think anyone with this kind of mental illness will be drawn to the Allman style. It's Feng Shui, man! :cool:
Feng Shui for dim-wits, I think you mean. A sort of false Feng Shui, aka anal retentiveness -- you are much closer to the truth when you call it neurotic.
I studied perl before C and had the exact opposite experience re: formatting and indentation. Not that I did not systematically indent and format my code, I just did in a somewhat more concise manner. The perl issue around "use strict" (pretty much settled by now) might be a parallel since it involves scoping, but in a syntactically meaningful way.
However, I am gradually enjoying more widespace as I mature. But I would never go allman unless forced to.
However, if you make a "high quality code" mentioned on "Code Complete" book, using PDL you'll definetly prefer the #1 style.
instead of..Code://whenever the current element's value is more than the next element's
if(element[i] > element[i+1]) {
//then swap the current element to the next one
swap(element[i], element[i+1]);
}
Code://whenever the current element's value is more than the next element's
if(element[i] > element[i+1])
{
//then swap the current element to the next one
swap(element[i], element[i+1]);
}
Still prefer the Allman style.
Now here is a kicker: If you can't handle using any spacing/bracket style that is throw at you then you won't be very useful. Allman might be my preferred style but if I'm touching code in a different style then I'll use the same style.
>if you make a "high quality code" mentioned on "Code Complete"
>book, using PDL you'll definetly prefer the #1 style.
I don't see any meaningful difference. Could you point out why the #1 style is so preferred over the #2 style when using PDL?
What is PDL?
Elysia: Did I say styles absolutely does something to quality?
Prelude: Did you try it?
I'm in the terrible position of having a family member with severe obsessive compulsive disorder. Needing to have things at just such an angle is not even remotely close to the horrors. I don't want to get into the depressing details, but it's not about quirkiness. It's a complete inability to function in the real world.
Have you seen Jack Nicholson in the movie "As Good As It Gets?" That doesn't even remotely come close. It's a debilitating, terrible, awful, disease that not only ruins your own life but that of everybody around you who cares about you.
Jeez.