Tuesday, December 15, 2009

Agile Development - Code Review and Continuous Builds

Hi, I'd like to share my point of view about some specific methodologies or "best practices" in agile development. We can read in almost everywhere some basic points:

Convention over configuration
Optimize Later
Test Driven Development
Refactoring
So on...

This time I am going to talk about refactoring code, and I will start asking: why do we need to do "refactoring"? In my personal opinion this will only be performed in Optimize Later, because, in development stage you have to guess the bottlenecks and real data is needed to improve optimization. If the team has solid vision about software development and the product, then, why would we submit "ugly" code that later will have to be refactored in a nicest way?, why would we loose precious time after deliveries refactoring, testing and releasing?


I'm convinced that collaborative development is the way to go, so, if your team implements solid code submitting work flow, then you will became more profitable and will deliver better products, this is, a good code review process will lead your team to submit code that has been reviewed and approved, and anything else, no ugly code, no breaking code, etc. I know that code review is one of the most boring task for engineers, but if you could convince your Seniors that they wont spent their time in nothing all the team will learn a lot!

And, how do we encourage our Seniors to review code? Easy, assign them code to review that has passed unit testing, code that is not breaking anything else and that is well written. Ok that sounds great, but How!

Git + Gerrit + Hudson = Truly Agile !

Imagine this: Developer does his Job, write code and its unit testing, pass his code throw a "Lint Program" and detects possible ugly code ( lines with more than 100 chars, wrong indentation, spaces between params, so on), once the code is ready, then submit your code to review (Gerrit), Gerrit sends a notification to Hudson to fetch the change, build it and run all the unit tests, if it passes everything, then use Gerrit command tools to approve the change, did you notice that at this point the code is ready to get reviewed by a Senior Engineer?, why? Just because the code is not ugly (Lint Script) and it's not breaking anything else (Continuous Build), So your Senior Engineer will be pleasured to review that code and he will be sure he wont spent time reviewing something that may break something else.

If you can reach this workflow, your team will be really Agile! and you will be avoiding precious time after development that normally would have to be spent refactoring code, why is this true? It's simple, because you wont have ugly code in your Git Server!!!!! whohoooooo.


Git: Best free source versionning system (For me)
Gerrit: Code reviewer System, web based and developed by Google to review Android Code
Hudson: Nice Flexible Continuous build server.

No comments: