9 Replies - 2539 Views - Last Post: 19 January 2011 - 09:02 PM

#1 Mila  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 34
  • View blog
  • Posts: 193
  • Joined: 28-October 06

Code Style and Style Manuals

Post icon  Posted 18 January 2011 - 04:03 PM

Many software companies have Code Style Manuals that their employees need to adhere to. Generally these contain useful rules such as "name your variables based on what value they hold" and "don't embed ternary operators" and "always add javadoc comments to your classes." There are a number of cases when such manuals would come in handy, such as in the course of a code review, or when you inherit a coworker's code.

I recently took an Advanced Java Programming class where the professor, who was a part-time professor and a full time programmer for a really-big-really-famous software company, who bemoaned the fact that students enter the working world and simply aren't prepared to adhere to a coding style because they've never been forced to adhere to one in a class. (Then he proceeded to foist a required coding style on us that included, among other things, such annoyingly un-useful rules like "don't use tabs, use a single space to indent.")

My question is three fold:
1. Does your current employer, or school, or class require the use of a code style or have a style manual? (Or, if not, have you ever used one?)

2. Do you find the concept of a style manual to be useful? Do you find it useful in practice?

3. Should code styles and style manuals be enforced in schools and educational institutions to train programmers in their use and foster better coding skills?

Is This A Good Question/Topic? 4
  • +

Replies To: Code Style and Style Manuals

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2872
  • View blog
  • Posts: 11,031
  • Joined: 15-July 08

Re: Code Style and Style Manuals

Posted 18 January 2011 - 04:09 PM

1) I'm self-employed and self-taught, so not officially; however, using the official Java style guide is always what I follow.

2) Absolutely. It universalizes Java code in a way that nearly everybody else can understand. It helps to self-document code so that it is easily readable. Also, when going through the APIs, I know that all get methods return values in the object and set methods set them. Things like that make style guides absolutely great in practice.

3) Yes. Look at my answer to #2.

I am going to Feature this and move it to Corner Cubicle for better exposure.
Was This Post Helpful? 1
  • +
  • -

#3 Luckless  Icon User is offline

  • </luck>
  • member icon

Reputation: 292
  • View blog
  • Posts: 1,146
  • Joined: 31-August 09

Re: Code Style and Style Manuals

Posted 18 January 2011 - 04:18 PM

I am also self taught, but now that I'm working as an undergraduate researcher, me and my co-workers appreciate being able to read each other's code, so yes, we do stick with the universal style. If you go into a novel understanding the structure of the book itself, you have an easier time understanding what's going on.

Mashed 1, 2, and 3 together, but tough luck, the little anarchist in me says, "deal with it". Didn't that make my response a little harder to comprehend? :P
Was This Post Helpful? 0
  • +
  • -

#4 Agentsnakezero  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 34
  • Joined: 28-September 10

Re: Code Style and Style Manuals

Posted 18 January 2011 - 04:32 PM

1)I am currently in a Ugrad program and we are "told" to have a certain style with the code but when it actually comes down to it many of the professors dont care as long as the code works and they can decipher it. Personally I use closer to the Java style manual that anything else unless i am doing something quick to prove a concept or whatnot.
2)I do think it's important to have a style manual but when it gets down to the nitty gritty(tabs vs spaces, and braces location) it doesn't bother me either way.
3)I do but again as long as the code is readable the arguments about tabs vs spacing are like fung shui, some people have one opinion, others another
Was This Post Helpful? 0
  • +
  • -

#5 diego_pmc  Icon User is offline

  • D.I.C Addict

Reputation: 81
  • View blog
  • Posts: 565
  • Joined: 13-May 09

Re: Code Style and Style Manuals

Posted 19 January 2011 - 05:12 AM

I can say I know Java so I'll refer to C++. This is a pretty general subject anyway, so it doesn't matter.

1) I don't work yet and I am autodidact when it comes to programming. In school they never imposed a coding style, and I'm pretty sure no one in the class besides me and maybe a couple of other people would care about that anyway (maybe not even the teacher).

2) Most defenetly. A very good coding style helps the reader understand the code better and can understand things about the functions, the data, etc without actually looking at their definitions. Some C++ coding style guides I found very useful are Geosoft's and Google's. Here's also something on Hungarian notations.

3) Yes, it helps students write better code and gets them used to working in a way that is expected of them in the industry.
Was This Post Helpful? 0
  • +
  • -

#6 karabasf  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 202
  • View blog
  • Posts: 417
  • Joined: 29-August 10

Re: Code Style and Style Manuals

Posted 19 January 2011 - 06:20 AM

1) I currently work and study. I know there is a code style at my work, but they have yet to introduce me their code style. Furthermore, I think that because I am currently working on a pilot program of the company. Everything is just a mere orientation phase and it still has to be decided if they want to continue with it.

Furthermore, everything I've learned till now, regarding programming, is all self-taught. And regarding diego_pmc's remark: same for me. I think at my study (where there are a few programmers, because they all think engineering is all about.. well engineering) there is also nobody (save for a few teachers) who cares how the code looks like. As long as it works, it is all fine to them, no matter what it looks like.

2) Yes, the concept of a manual is quite important, if it is universally applied. Except that it makes your code understandable for others, it makes the code of others understandable for you. At my work, we have several libraries, each containing a lot of methods, which you can use.

Though, before I worked (and maybe before I seriously started programming), I didn't care about style formatting. But recently (take for example the pilot program) it has been nagging me that I am not using a code style. What if they plan to continue with the current program and want to make it commercial?

3) yes, because what I now notice (because it wasn't 'enforced' on my study) is that I lack a decent code style. Just until recently, I started to look up about about different style guides. Being a JAVA programmer and now a C# programmer, I am now trying to get used to this format:
https://docs.google....2g8k89pf7&pli=1
Was This Post Helpful? 0
  • +
  • -

#7 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Code Style and Style Manuals

Posted 19 January 2011 - 07:40 AM

1. Does your current employer require the use of a code style or have a style manual? (Or, if not, have you ever used one?)

Yeah after the first month we were giving a coding manual to glance over. Luckily 99.9% of the things in manual were things I was already doing on my own. :)

2. Do you find the concept of a style manual to be useful? Do you find it useful in practice?
Yes, tremendously useful. It maintains a visual style of the codebase and doesn't force you to read horrible eye-gouging LOC.

3. Should code styles and style manuals be enforced in schools and educational institutions to train programmers in their use and foster better coding skills?
Absolutely. I sometimes see code from my senior classmates and it looks horrible. Crappy variable names, wierd indentation, braces wherever they please. :x Please no!
Was This Post Helpful? 0
  • +
  • -

#8 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10567
  • View blog
  • Posts: 39,117
  • Joined: 27-December 08

Re: Code Style and Style Manuals

Posted 19 January 2011 - 08:35 AM

1) No.

2) There are certain good coding and design practices. I think beyond that, if we're focusing too much on things like standardizing how much or how little one indents or spaces their code (beyond readability), then we're being a little too anal retentive.

3) Within reason. Again, let's try to encourage readable and maintainable code rather than being anal retentive about two spaces vs. three spaces.
Was This Post Helpful? 0
  • +
  • -

#9 Jstall  Icon User is offline

  • Lurker
  • member icon

Reputation: 434
  • View blog
  • Posts: 1,042
  • Joined: 08-March 09

Re: Code Style and Style Manuals

Posted 19 January 2011 - 08:41 AM

Code standards on a project are definitely useful as it maintains consistency and makes understanding code written by other people on the same project easier as it is in a familiar format. I have attempted to decipher some pretty poorly written code in my short career and I can say having consistent standards made a difference.

This post has been edited by Jstall: 19 January 2011 - 08:42 AM

Was This Post Helpful? 0
  • +
  • -

#10 Guest_ernie.cordell*


Reputation:

Re: Code Style and Style Manuals

Posted 19 January 2011 - 09:02 PM

View PostMila, on 18 January 2011 - 04:03 PM, said:

Many software companies have Code Style Manuals that their employees need to adhere to. Generally these contain useful rules such as "name your variables based on what value they hold" and "don't embed ternary operators" and "always add javadoc comments to your classes." There are a number of cases when such manuals would come in handy, such as in the course of a code review, or when you inherit a coworker's code.

I recently took an Advanced Java Programming class where the professor, who was a part-time professor and a full time programmer for a really-big-really-famous software company, who bemoaned the fact that students enter the working world and simply aren't prepared to adhere to a coding style because they've never been forced to adhere to one in a class. (Then he proceeded to foist a required coding style on us that included, among other things, such annoyingly un-useful rules like "don't use tabs, use a single space to indent.")

My question is three fold:
1. Does your current employer, or school, or class require the use of a code style or have a style manual? (Or, if not, have you ever used one?)

-- Yes: Not just in code, but in other forms of communication; maybe it all seems well and good until somebody comes along to give you something the rest of the team can't follow.

2. Do you find the concept of a style manual to be useful? Do you find it useful in practice?

-- Not only useful, but necessary: In the real world, people have to produce on-time, quality product. Employers know that sticking to certain industry norms allows the greatest success with the usual tools and materials.

3. Should code styles and style manuals be enforced in schools and educational institutions to train programmers in their use and foster better coding skills?

-- To me it seems obvious that an educational or training institution should prepare a student for the work environment; to do anything less seems something of a fraud. As it is, it already seems to me that "training academies" raise expectations of employment among average students when the truth is that only the exceptional are going to generate significant income. To accustom the student to anything less than what is expected in the workplace is somewhere between a fraud and a lie. People need to be taught what to expect and what will usually work: That's almost more important than the subject material.

Was This Post Helpful? 0

Page 1 of 1