Coding Standards

Published Sun, Jan 23 2005 23:06 | William

Hopefully I'm not divulging anything I shouldn't, but I got this email recently:

<<I know everybody gets tired of me harping on this, but please follow the coding standards.  Some places that these were not followed are:>>

I could show the exact examples, but I had 5 violations of our coding standards.  A few years ago, I probably would have gotten all defensive and had some rationalization like “Well, if this is the worst I did than I must be doing pretty well.”  But to be honest, all it would have been was a rationalization. 

Where I work currently, we have more than a few very large roll outs in production.  When I say large I mean 30+ assemblies, with a LOT of functionality in them.  I've been there since August 20something of 2004 and to date, we have not taken one single support call due to a bug or us missing a requirement. Your first thought is B*** F**** Sh1t - no body gets it that right - or there must be something else to it.  Well, there isn't.  Typically one of our smaller projects is probably at least a 1/4 million dollars and a few of them are substantially larger.  But a few things I can say that we get VERY RIGHT!

1 - Understand the problem and the solution - Period - end of story.  We put a tremendous amount of effort into this - a LOT.  When I first started working there, my biggest deficiency was my skills in Word and Visio.  If you don't know what you're building then you have issues.  But at more than a few places I've worked - the Programmers would build what they thought the users wanted - and if the users didn't like it - well, we'd either change it or blame it on the stupid users. 

2- Doing things right the first time is always quicker and cheaper than doing them over.  Or, “Measure twice cut once”.  Or, “the longest distance between two points is a shortcut.”  This means we spend a lot of time writing and reviewing specs.  As a developer, this sort of blows.  But, it's necessary and having worked in NO spec environments, I wouldn't change it for anything.

3- Ownership - Everything is owned by the person that wrote it - but the whole team shares ownership on the success of the project.  The whole notion of “Well, it's His problem” doesn't exist, not at all.  That's simply not an excuse

4- Testing.  I actually worked at a place with Kim that had their quality control policies written out on an Index card that was photocopied.  It basically came down to “Make sure you test your stuff becuase if you don't, it'll be bad”.  We had testers OBSESSED with Tab Stop issues, color schemes, and all sorts of other stuff that 'matters', but only if the product worked.  On our payroll program, we paid someone like 10 or 11 million on week because of an overflow that the developer missed, and so did our genius testing team.  But dammit, our Tab stops were right, even on those screens that no one ever used.  The only reason we found out was becuase the IRS stopped the transaction b/c it set off all sorts of Money Laundering Alerts.  They contacted the bank, who contacted the client, who contaced us (Next time you hear someone tel you that we can't lower taxes without cutting vital services, please drop me a line btw).  Guess who that company blamed for this?  Come on, Guess!  Yes, the Client - they should have run reports that would have caught this.  Literally, our response was that it was THEIR fault for not catching it - we gave them reports after all. [Since you may be disinclined to believe me here, hit google, go to Groups and search on Smithdata.net -  most of those questions were asked by the all - star developer).  The truth is, all of it matters.  If you are too busy or too smart to please your clients - no worries, someone else will [See, I did learn something in MBA School].

5- Taking pride in your work - at every level, particularly the higher up you go, you see Pride in the company and pride in the product.  As such, you couldn't really miss the fact that if you did something knowing full well that it would affect the customer - it wouldn't go over well (to put it mildly).

6- Turnover - as in almost none.

----------------------------

As someone who's favorite variable name is 'x', I've had to adjust.  It's frustrating at times b/c the learning curve on coding standards is not small.  But think about it - if you can't even camelCase your variables when they should be PascalCased without it throwing up flags - if you can't even forget to comment a code block in its entirety without it getting caught - what are the chances major code flaws are going to slip through the cracks?  Nope, because code reviews start with the important stuff (like do the numbers add up, how much stress can things take etc) and work down until the smaller issues, like variable names and case.

We hear tons about how companies screw up - but not nearly as much about how they get things right.  What are some things your company gets very right?

Filed under:

Comments

# William said on January 23, 2005 11:11 PM:

I've given up on coding standards. It's like making a german guy dream in english - it's in the DNA of a developer, and the purpose behind the coding standards - legible maintainable code - is often lost in the means of the fight.

As long as basic functionality remains, and people don't circumvent the data layer - in my team atleast - they have the freedom to choose their own coding standards unless of course they are totally ridiculous. Usually through a back and forth discussion I have been able to come up with mutually agree-able standard in my team.

# William said on January 24, 2005 1:29 PM:

I do a lot of SalesLogix coding, well in the span of 5 years I've seen my share.

Sadly because I'm one man, and when people request something it's needed YESTERDAY, specs aren't done. The closest thing I have to a spec is a sketch me or my dad put on paper of the basic idea.

The good side of that is I get to pound whatever idea into the final weapon it becomes. I know how I can manipulate SalesLogix and the database to give me aproximately what I need. It's never quite perfect but I could spend days on deciding database fields when I could just throw something together and add the fields after I've worked up a decent prototype. I also don't comment my code much, use debug.asserts (now that I can I'll probably play with it to see where it'd be useful) and a couple of other no-nos in another shop but my excuse: I don't have the time. I'm IT so everything computer related comes to me, the fact that I can code is just an added bonus that is never fully understood. I'm juggling different responsibilities and workflows and I haven't fully commited to just one which is the problem.

I recently got a request to possibly do some SalesLogix work for another company as a subcontractor but I haven't responded back. I haven't been given good practices to begin with so I'm kind of reluctant to work for someone else. What I do here is sufficient but trying to reliably track work for someone else will be difficult to do without proper education. Teaching myself is taking a lot more than I would like as I'm not devoting the time I need to better my standards.

I've thought this way for a while and I know I'm crazy but I'm trying to work as if I have amnesia. I'm trying to develop a system that if I have no memory of my past that I could reliably pick up my job as if I didn't miss a day. This would involve a massive brain dump of many things I keep track of but such a system is quite possible if done correctly. Most of the problem with teaching yourself is you tend to follow the shortest path which may not always be the best. While I can do my work, documenting it is a very different subject that almost seems impossible with the way I function.

# William said on January 24, 2005 4:26 PM:

I wish we had code reviews here where I work, there are none...there are coding standards but they are not enforced and therefore are not really followed. But with that in mind I do what you suggest in point 5 - I take pride in my work and therefore I adhere to my own coding standards; which IMHO are pretty good. There's virtually no testing done on our stuff either...the programmer tests it then the analyst tests it and it goes into production - and it's all tested with correct data and tested by doing exactly what has to be done in the application. This would be the ONLY thing that I don't like about where I work, I love it here, the people, the opportunities I get to use all types of hardware and software, and the fact that I get paid to learn (That is the greatest part of my job IMO).

# William said on January 24, 2005 4:27 PM:

I wish we had code reviews here where I work, there are none...there are coding standards but they are not enforced and therefore are not really followed. But with that in mind I do what you suggest in point 5 - I take pride in my work and therefore I adhere to my own coding standards; which IMHO are pretty good. There's virtually no testing done on our stuff either...the programmer tests it then the analyst tests it and it goes into production - and it's all tested with correct data and tested by doing exactly what has to be done in the application. This would be the ONLY thing that I don't like about where I work, I love it here, the people, the opportunities I get to use all types of hardware and software, and the fact that I get paid to learn (That is the greatest part of my job IMO).

# William said on January 24, 2005 7:35 PM:

When i started here we didn't have any code or development standards at all...i'm anal about standards and force it on everyone i work with..

needless to say, i sat down and wrote a spec document for our coding standards, passed it around and discussed it at our dev meetings. It's been passed and we're now running by it.

Loads of small changes and additions coming up all the time but at least we're working on it.

One thing i've always hated is when a PM (i know, always shoot the PM) handballs you jobs and projects and expects you to do the documentation. You have no client interaction so you wouldn't have a clue as to what they really need - basically you go by instinct and experience.

That was mostly the case when i started - then the PM (finally) left and we were on our own. Now we run spec documents and sign-offs on everything that's done. If it isn't clearly specked up, it just gets given back or we give it a shot and hand's it back to be reviewed.

One thing i do envy at your place Bill, is the fact that you work with Visio...i love Visio and would really really like it if my guys here would start taking it up and using it more frequently.

Anyways, you asked was is done right here - i'd say we do the work properly but does lack on the documentation (unfortunately) in some cases, but mostly we do alright there.

As a side note - you looking for danish programmers rowing over from Australia at your place?

# William said on January 25, 2005 7:57 PM:

Skicow - yeah, even if you company doesn't care about those standards, having them can still save you a lot of time. Unit testing is probably one of the things that's saved me the most time in terms of bang for buck too - but a lot of places don't get it - and just get mad.

Search

This Blog

Tags

Community

Archives

News

My other sites

Cool Stuff

Book Stuff

Security

ORM

Data Access

Funny Stuff

Compact Framework Stuff

Web Casts

My KnowledgeBase Articles

My MVP Profile

Design Patterns

Performance

Debugging

Remoting

My Fellow Authors

My Books

LINQ

Misc

Speech

Syndication

Email Notifications