|
All coding styles suck. But it's important that everyone in a project is using the same general style to keep the code readable. When available I prefer platform standards/IDE autoformat defaults. (And yes that means I use different brace placement styles in C# and Java.)
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
A person's style is like pot, everyone likes something different!
I do all my own stunts, but never intentionally!
JaxCoder.com
|
|
|
|
|
I like standards. I'm button-down that way.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
There is only one (sensible) standard:
The code can be read by another programmer without needing a decoder-ring - consistent with it's own standards and the intent of being informative to not only ones self, but with others who cares to look at the code.
Consider that, even for a given language, a different type of project can be best served by code that is emphasizes its constructs as plainly (and maintainable) as possible.
Also, if it's VB6, just chop off their hands.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
all true, and yet the unsensible is perhaps underrated.
some of the most inspirational bouts of coding I've had have left me with something I couldn't understand later.
not that I appreciate that entirely. it is what it is.
but yeah, I at least try to make the function names clean if it comes down to that.
plus, have you ever noticed how sometimes, code as it matures can get a bunch of weird forks in its codepath to handle one-offs and bugs, sometimes in other systems its interacting with, and so the simplest, cleanest solution doesn't work in the real world.
The truth is, I distrust all of this. It makes me uneasy. But it's a reality.
The best one can hope for in those situations is to keep the interfaces as clean as possible, comment what you can, especially the corner cases, and wave a dead chicken over the whole thing.
And that's perhaps where software breaks from engineering into art.
=)
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
codewitch honey crisis wrote: some of the most inspirational bouts of coding I've had have left me with something I couldn't understand later. Let me tell you about a closely guarded secret: comments!
Orders of magnitude more valuable than wasting mind and body on some OCD organization of symbol and function names.
Rule-makers aren't sitting with you seeing the problems you need to solve.
If you've ever built a database then you may have come to a time where normalization just isn't the best choice - you break it in a strategic spot for simplicity and efficient execution. The basic rule of thumb: do it the best way you can.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
comments are cool, but have you ever implemented an algorithm before you understood it?
how do you comment that effectively?
for me, what happens is, I code it to learn it. Maybe over the course of weeks, months, even years, depending on what it is I'll refactor or even rewrite as I understand the problem domain better.
As I do those refactors and rewrites I can and do add comments.
Maybe it's because I think visually so my process to translate algo to code is weird or something, but I'm sure I can't be the only one who does this.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
codewitch honey crisis wrote: comments are cool, but have you ever implemented an algorithm before you understood it? This can be taken two ways:- You're just translating equations to code and are otherwise clueless about its worth
- You're not an expert in the algorithm
Decades ago I translated 4th order runge kutta fit into FORTRAN. As I translated the equations to code I had some idea what it was doing but not really very well. Nonetheless, I could still comment whatever wasn't the most obvious coding translation, or where I twisted it around a bit so it was more efficient. What variables I passed as Globals on one end and where they came from on the other. Comments can be improved as you understand or just learn to code better.codewitch honey crisis wrote: but I'm sure I can't be the only one who does this. True - OCD is not a single degree of behavior. It has a smooth implementation. I, for example, really like my curly-braces to be the way I like them (which visually sets off the code blocks as my eyes prefer it). On the other hand, in SQL, I use recid as my identity column. My 'boss' uses rec_id. Our data is very intimately integrated. As Kurt Vonnegut would say: "So it goes." Besides, we can tell each other's tables apart. We also pick up things from one another - change styles and methods if we decide another is better. No one's ever thought to set up rules for the column names.
In fact - I'll use some spin and argue it's better this way: since nothing is an absolute 'given', we're required to pay attention to what we're looking at. Probably saves a lot of profanity down the line.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Coding standards are like religion. It's fine to have one, but please don't force yours on me.
/ravi
|
|
|
|
|
I am just trying to let go of some of my uptightness around the standards of others. =)
We agree. I mean in principle. Intellectually speaking, but my heart isn't there yet.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Don't want to sound philosophical, but a couple of years ago I experienced a back injury that made it impossible to sit or walk normally for 3 months, which meant I couldn't do what I love doing most - i.e. writing code and building software. During that time I was forced to work from home (standing up, with much difficulty) and participate in meetings remotely. It was during those meetings, many of which included animated discussions (and strong feelings) about coding standards, unit testing and other software development related processes, that I realized what was really important. Yes, of course, I'm talking about one's health. It seems as if I had to experience that injury in order to get my priorities right.
I'm still (very) passionate about my craft, but I seemed to have grown a large pair of ears. Today, I tend to be much more sensitive to other people's opinions than ever before. My only regret is, I wish I'd come to this realization earlier. I would've learned so much more from my (much smarter) colleagues.
/ravi
|
|
|
|
|
|
|
Shouldn't your user name be in Title Case?
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
haha
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
The problem with coding style guides is that they try to put everything in it.
Just start creating one with only a few guidelines that are easily enforceable.
I'd rather be phishing!
|
|
|
|
|
The style guidelines for my group are a little over one page in length, and are mostly naming conventions. I can summarize them as follows:- Names should not rely on tribal knowledge for interpretation (use whole words).
- Non-local names should use Pascal or camel case.
- Local names should be in lower case.
- If it's public, capitalize the name.
- If it's private/protected, prefix the name with an underscore.
- Acronyms embedded in a name should be prefixed and/or suffixed by an underscore to ensure the acronym is readable.
- Hungarian notation is strongly discouraged.
- Above all, BE CONSISTENT.
We don't prescribe brace style or other formatting (e.g. tabs), source organization, language features, or most of the other things that people argue about.
Software Zen: delete this;
|
|
|
|
|
Nothing should ever be camelCase.
|
|
|
|
|
Agreed. I don't like or use it myself, but we had a couple folks who liked it.
Software Zen: delete this;
|
|
|
|
|
codewitch honey crisis wrote: To the point where I usually kick myself for not putting constants before vars in equality comparisons if(0==foo), etc.
I've never liked that one. Yes, I know it stops the "=" vs. "==" mistake but it just doesn't read the right way.
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
|
|
|
|
|
I've grown to like it because if you tab everything out, it makes the constants easy to put into columns and read from the left.
But that's only applicable when you're doing a lot of comparisons in one test, like in a state machine transition.
Still, sometimes its elegant. Other times, maybe most times, i tend to agree with you but i suck it up and do it anyway, like eating an orange (i hate oranges)
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
It's a Catch-22 requirement. The rule is to help people who are unaware of the problem it is intended to solve. As soon as you are aware of the problem, you don't need the rule. As soon as you know the rule, you are aware of the problem so are unlikely to fall foul of it.
|
|
|
|
|
Plus, any self-respecting compiler released in the last 20 years issues a warning for "assignment in conditional expression".
Software Zen: delete this;
|
|
|
|
|
This. This is my main problem with style guides: sometimes technology catches up and the rule isn't needed anymore.
|
|
|
|
|
codewitch honey crisis wrote: I'm half serious about this post. Which half?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|