User: Password:
|
|
Subscribe / Log in / New account

Consistent coding style

Consistent coding style

Posted Feb 29, 2008 19:37 UTC (Fri) by giraffedata (subscriber, #1954)
In reply to: here, here! by sbishop
Parent article: Merging drivers early

We had two professors who taught the introductory courses, one who enforced a coding style and one who didn't. The other assistants and I often commented on how much easier it was to help the students in the class where a consistent style was enforced.

Was it because the style was consistent or because the professor picked a good style?

I spent the early part of my software engineering career at a large company that had company-wide coding standards. I was taught, and believed, that it is easier for someone to read code where the indentations are where one expects them, the variable names in the case one is used to, etc. Later, I started working with open source code written by the public at large and found that it's actually trivial to adjust to someone else's style, as long as we're just talking about arbitrary style differences.

Adjusting to a bad style, such as using global variables or 500 line subroutines, is obviously another matter.


(Log in to post comments)

Consistent coding style

Posted Mar 3, 2008 3:48 UTC (Mon) by jzbiciak (subscriber, #5246) [Link]

I'm sure part of it is due to picking a reasonable style.  Inexperienced programmers don't
necessarily know what "reasonable" is yet.  I wouldn't doubt, though, that a good part of it
comes from the benefits of consistency across a code base.

Part of the reason it's often easy to adjust to a given FOSS project's style is that it's very
likely to be reasonable and consistent across the source base.  Once you get accustomed to the
particular style/flavor, it's easy to see through it to the code.  The fact that each source
file has the same style helps.  Sure you have to switch gears when you come to the project,
but you're not doing it file to file.  You're doing it project to project, which is a pretty
coarse grain.

In the context of grading coursework, I see both aspects playing a role.  You've gotten the
students off on the right path by giving them a (hopefully) reasonable style.  Also, since
each assignment should be using the same style, you aren't having to switch gears with every
source file.  When you are grading 100 assignments, I'm sure that makes a lot of difference.



Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds