IronShay

Ironing code, geek t-shirts and even presentations!

NAVIGATION - SEARCH

How to Increase Code Quality

A while ago we decided on my team that we needed to increase our code quality. We were excited about that and thrilled to get it started with.
Then we looked at each other eyes, saw the passion to write better code but… something was missing!

How to Increase Code Quality - IronShay.com

When you think about it – how do you write better code? how do you increase your code quality?

With the help of the great people on StackOverflow, I managed to gather a list of principles that can take your code to the next level:

Testing

Learn how and write write write tests! you don’t have to go for TDD, but remember to test your code  and make sure it runs as  it is expected to before it leaves the dev environment. Tests include unit and regression tests.
You can use NUnit, TypeMock  for .Net languages or other testing frameworks (every language has some).

Code Reviews

Allow other developers to go through your code before you’re done with it; You and them will learn from that.
There are tools to help you with the code review process like Crucible.
I must say it’s magic! we implemented that on our team immediately (no tools currently, we just sit with each other) and several bugs have already been prevented because of that in only a few weeks!

Standards

Agree on coding standards and stick with them. This will help you understand other developers' code, reduce different code blocks that handle for the same issues and prevent bugs eventually.
Standards include:

  • Coding standards – naming conventions for example.
  • Exception handling standards – how to handle exceptions throughout the application.
  • Logging standards - how and when to write log entries.
  • Whatever you and your team decides on.

You can enforce standards with third party tools like: FxCop, StyleCop or Code Style Enforcer.

Use Tools to Help you Code Better

Like Resharper.

Design Reviews

Design before you start coding and get your design reviewed before implementing it.

Read Related Books

Like Code Complete: A Practical Handbook of Software Construction or other books.

Talk and Meet with your Team

Talking makes wonders. Talk with your colleagues frequently and schedule a weekly meeting where every developer presents one interesting or important piece of code he/she have written during the week.

Coding

  • Try to simplify the problem as much as you can.
  • Try to break the code into small and well defined functional units (folders, files, namespaces, classes, methods) to keep the codebase logically organized and well structured.
  • Document the code. Document it so your colleagues will understand it without your help.

Source Control

Work with a source control system like SubVersion, CVS, Git, Team System or others.

Learn Other Languages

Even if those languages are not appropriate for your production code, you can find ideas in them and you can build your own internal tools with those languages.
My recommendation - learn IronRuby!

Own a Build Machine

A continous integration machine which automates the build process is a life saver. It can automatically build the application after every commit (or whenever you tell it to), run unit tests and create a setup project that people can immidiately go and install. It saves so much time! it also saves you from hitting your head against the wall when doing these repeating tasks youself.
Look here for a list of continuos integration applications.

I liked what Mark has written so I'm going to finish with that: "Quality is Free -- quality is conformance to specification and is built-in, not bolted on".

All the best,
Shay.

kick it on DotNetKicks.com

Shout it

Comments (2) -

This is a good checklist on applying a methodology to coding.

Reply

This is one of the most useful articles I've recently read. Code quality is something which is usually ignored in small-teams (even large-teams) and would result in higher costs in maintenance phase.

Reply

Pingbacks and trackbacks (3)+

Add comment