Monday, October 5, 2009

Ten things you can do to eliminate bugs and increase your company's overall code quality


Probably one of the most difficult things about maintaining a development shop is that you can't always be around to make sure that (1) all your company's projects are bug-free, and (2) that the morale of your development team(s) remains at the highest levels. In practice, this situation can often become a nightmare if your development team is scattered across multiple off-site locations and don't even share the same time zone. To make matters worse, you have to ensure that every line of code in your company's code base is fully tested, commented, and documented so that you can promptly deliver it yesterday in time for the release deadline.

With that much chaos in mind, one might even think that we'd be in some sort of a code quality crisis here at CodeLean; however, our code metrics for our projects show a completely different story:

Average Cyclomatic Complexity1.81 (StdDev 1.96)
Average Test Coverage Rate95.9%
Average FxCop Errors
Average StyleCop Errors
Code Documentation Coverage

Now, if you're not familiar with some of the metrics above, the table just means that we can keep our code quality extremely high with only a minimal amount of effort, regardless of project size or scope. In other words, our projects can be composed of several hundred thousand lines of code, and we can still guarantee the same level of quality. In this post, I'll show you a few things you can do with your development process and your development team to make your projects just as efficient.

Inhumanly Possible?

At first, this might seem impossible--after all, one might be dealing with thousands (or even hundreds of thousands) of lines of code per project, and it's hard to go through line by line of
that much code and ensure that everything works just as advertised. So the next question that you might be asking is "How can you guarantee that your code meets the standards above if it's not humanly possible to inspect that much code, and still meet the client deadlines?"

QA Specialists to the Rescue?

Indeed, such code quality inspections can be done by an army of quality assurance specialists, but there's no guarantee that they will be able to catch every QA issue from your development team. The problem with this approach is that it can't scale, because the ability to inspect your code base largely depends on the number of people that you have available that can inspect it. In other words, it's a huge bottleneck, and that's where build automation can come in handy.

Automating Code Inspections

The best way to ensure the quality of your code is to use automated code inspection tools (such as StyleCop, FxCop, and Gendarme) to catch QA violations during your application build process. These tools can eliminate the tedium that is often associated with having your QA teams manually inspect each line of code in your code base. Furthermore, automated code inspection tools can typically inspect code bases of any size, making it easier to inspect your systems without having to pay an entire QA team to perform the same task.

Add Code Quality Metrics

Beauty in Objectivity

One of the best parts about having code quality metrics calculated during each build is that it forces all your developers to adhere to a single set of standards without any form of bias from the code reviewer (or in this case, the automated code inspection process). Secondly, it eliminates many of the conflicts that arise between developers during the course of multiple code reviews since the automated code metrics will force all your developers to follow a single standard. This will allow your developers to work in tandem without stepping on each other's egos, and at the same time, it will also ensure that your code metrics never fall below a certain threshold.

Fail Any Build That Does Not Meet Your Company's Standards

If your developers write code that fails to meet the threshold, however, then your build process should automatically fail itself in order to prevent your developers from adding substandard code into your projects. At first, this approach might seem a bit too stringent, but in practice, it forces developers to fix the quality of their code before committing the changes back to the code repository. This particular approach also teaches developers to think about the design of their code before making any unnecessary changes, and it also prevents developers from hastily committing unrefactored code that might have otherwise been overlooked in a manual code inspection.

Automate Your Deployment Tasks

Application deployment is arguably one of the most critical and mundane tasks that any developer team can undertake. More often than not, a single configuration error can mean the difference between a company shipping a well-designed product website or having the same company display a "404 - Page Not Found" error within a few minutes of having their Web site go live into production. Since many deployment tasks (such database deployment) are repetitive, the best way to eliminate such last-minute deployment problems is to put all the deployment tasks into automated deployment scripts. Automated deployment scripts eliminate the chronic tedium associated with manual deployment, especially when it comes to deploying database applications and deploying Web applications.

Database Deployment

Setting up and tearing down databases during manual deployment can potentially cause version conflicts between the production code and previous database versions. Suffice to say, it can be difficult for developers to synchronize the application code with the database code over the course of the application's lifetime. In many cases, it's far too easy for developers to forget to deploy the correct SQL script or ensure that the application code writes to the correct version of the database. Indeed, there must be a better way to reduce the errors in deployment, and the most efficient way to do this is to use automated build tools like NAnt (for .NET) or Ant (for Java) to tear down and redeploy the database whenever the application needs to be updated or installed. Automated database deployment often reduces many of the errors associated with deployment by simplifying the database deployment down to a very few small steps. This allows nearly anyone on the development team to deploy the database schema without having to know everything about the deployment process, and that might come in handy if the application needs to be deployed immediately and the principal developers or DBAs are unavailable at the time of deployment.

Web Deployment

Web deployment, on the other hand, suffers some of the same drawbacks associated with database deployment. With manual Web deployment, it can be very easy to overlook or omit critical files (such as configuration files) when a Web project is being deployed to a Web server. Futhermore, manual Web configuration and deployment can also become quite tedious when your team is dealing with more than one Web server and it can easily get more complicated once your team starts dealing with multiple Web servers or Web farms. Like database deployment, most (if not all) Web deployment tasks can be automated, and this can save your development team some precious time if you're running on a tight schedule and can't afford to miss the project deadline.

Automate Your Web Acceptance Tests

Automated Web acceptance tools such as WaitiN and WaitiR eliminate the need for Web testers to manually check the features of your Web site. These tools allow you to take control of Web browsers such as FireFox, Chrome, and Internet Explorer, and let your tests interact with nearly any Web site without forcing anyone on your team to sit at the keyboard and perform the same steps over and over to see if they work as advertised. It might seem a bit unsettling at first, but watching these automated Web acceptance tests test your site by themselves (and without any form of human intervention) is practically a miracle unto itself. More importantly, automated Web acceptance tests can save you a lot time and money since nobody has to be at the keyboard when those tests run. Lastly, automated Web acceptance tools allow you to quickly find errors within your Web site in a matter of minutes. In contrast, it could take a Web testing team anywhere from a few hours to a few days to manually isolate the same bug if your team had made changes to their code. Speed is one of the benefits that automated tests provide, and needless to say, speed is one of the critical factors that can either make or break a deadline.

Make a One-Step Build

Allowing your developers to build your applications in a single step is one of the best ways to make your team more productive. This means that anyone on the development team (regardless of their skill level) will be able to automatically build, test, and even deploy your applications within a matter of minutes. You can use build automation tools (such as NAnt and Ant) to script the entire process. Although there is a slight learning curve in adopting these tools, there's no better feeling than knowing that you can roll out your entire app in a single step without slowing down the rest of your development team.

Use Continuous Integration

Continuous Integration is possibly one of the best investments that any company can undertake to ensure that their software is always in a releasable state. CI servers (such as TeamCity and CruiseControl) force developers to integrate their code changes on a daily basis, and they can easily help the upper management keep track of the overall health of the company's software development projects. Having your developers integrate their code changes on a daily basis means that more bugs can be found during these daily integrations instead of waiting until the end of the project to merge all the changes together. In other words, Continuous Integration can save your team an inordinate amount of headaches because it forces bugs to be fixed ahead of time instead of having them wait until the end of the project to resolve those same issues.

Go Green, or Don't Go Home

A CI server is typically in one of two possible states. It can be in a "green" state, which means that the current project builds itself properly and that all of its unit tests are in a passing state; or it can be in a "red" state, which means that the current project cannot be built or at least one of its unit tests have failed. One of the simplest ways to maintain or improve your company's software quality is to make sure that nobody on the development team goes home until the CI server is in a "green" state. Since the goal of Continuous Integration is to be able to create software that can be released on a daily basis, forcing the team to always leave the CI server in the "green" state ensures that your software can be released at the end of any given work day.

Use Source Control

Source control is undoubtedly one of the best inventions in software engineering because it allows developers to branch, undo, revert, restore, and merge changes in their source code that might have otherwise been impossible to perform if they were to use a standard file system to manage their source code. Source control makes it practically effortless to manage multiple versions of the same project at the same time. Source control management tools such as GIT, Subversion, and CVS all have the ability to branch multiple source files in any given project, and most (if not all) of these tools have the ability to track multiple file revisions to any given project during the course of its lifetime. Such tools can be a godsend when dealing with projects with thousands of source files because those tools make it easy to undo changes to an almost infinite number of files. In many cases, it only takes a single command or a single right mouse button click to revert a project back to the previous working revision.

Use Test-Driven Development

What if it were possible to perform regression tests on your entire application in less than five minutes? What if the same application could automatically tell you which parts of itself are broken, right after a developer makes changes to the source code? And what if it only takes a single person to execute a single step to run all these tests? How much would that be worth to your company? At first, this might sound too good to be true, but indeed, it's real, and it's called Test-Driven Development.

Needless to say, any project that can regressively test itself will be easy to maintain and debug since bugs can be detected during every five-minute test run. Since the tests only take five minutes to run, it's practically trivial for every member of the development team to test your application dozens of times per day before (and after) making changes to your source code. TDD allows developers to discover bugs faster than other more traditional development approaches, and more importantly, it forces developers to write their unit tests first so that the unit tests ultimately "drive" the design of the system. A passing test is often equivalent to one functional requirement, and since tests must be written before the actual code is written, every functional requirement that is implemented using TDD will automatically have a test that verifies its behavior even before the code is written.

Refactor Early, and Refactor Often

In many ways, it's easier to prepare for a disaster than be forced to experience it unprepared, and incrementally refactoring your company's code base is no exception. Refactoring allows developers to improve the quality and design of their code so that they will be prepared to handle any "disastrous" requirements that would normally wreak havoc on any reasonably sized code base. Refactoring preserves the original functionality of a code base without adding new features or subtracting any functionality. At first, refactoring might seem like an unnecessary task given that most clients don't care (or pay for) you to refactor their code. In fact, it's entirely possible for a company to work several years without having to refactor their code, so why should developers even refactor?

The answer is that as your code quality will inevitably plummet as your code base grows larger and larger. The longer you wait before you refactor your code, the more difficult it will be to add new features to the system without causing some other feature to break. In essence, every time the development team decides not to refactor their code, they incur a certain amount of technical debt. Much like financial debt, technical debt seems to have no initial cost, but technical debt can eventually lead a team's progress to a complete standstill if the debt is not repaid with refactoring. The easiest way to avoid technical debt altogether is to have your developers refactor their code as soon as they write it, and have them refactor it as often as possible.


A company that implements all these concepts under one roof will be well on their way to ensuring that they can deliver the world-class quality code that their clients rightfully deserve. The road to excellence definitely won't be an easy journey, but no matter where you go on this globe, we at Codelean will be there to help your company reach its full potential, so please don't hesitate to contact us if you have any questions.

--Philip Laureano
Codelean Lead Developer

Monday, September 21, 2009

Legacy Adventures 1 -- Characterization Tests

Working with legacy code cannot be avoided. Even R & D and open-sourced projects tend to involve a lot of maintenance programming. Working with another programmer's code has become a rite of passage, and many find it tedious. I'm pretty sure any developer would rather write new code than work with old code.

For those of you with a more advanced understanding of programming, working with legacy code can be a rewarding exercise. For one thing, most legacy code tend to behave as expected. If you're fortunate enough to be maintaining something with unit tests, count yourself as lucky. However, if the code does not have tests, then it's time to write some.

Even if the legacy code already works, writing tests are still important. Your changes should not break existing functionality. Tests written this way are called characterization tests. Such tests will look like a waste of time at first, but at least you don't have to bother somebody from QA to know if something is awry.

For example, I recently had a project in VB6. The code generates XML from a formatted string. They wanted me to read the data in one set of nodes, look it up in a database, and then swap the data given a set of business rules. My characterization tests tested all the nodes that did not get their data swapped. I was now free to code the new functionality.

So, working with legacy code isn't really a bad thing. You can learn many lessons from legacy code. Assuming you're working with well-written code, you can learn how to program properly. And even if you're not working with properly written code, you can practice skills that will make you write better code, or at least learn which programming styles create headaches.

--Jon Abaca
Codelean programmer
and consultant

Friday, September 11, 2009

Codelean’s 2nd ScrumMaster Certification Course—Raising Awareness of Agile Software Development in the Country

Codelean, Inc.’s second ScrumMaster Certification Course, held recently at the Dusit Hotel in Makati City, continued to raise awareness of Agile software practices in the country. The course was an even bigger success than the first one, with 25 attendees from software companies of different industries. Once again, Dutch Agile expert Bas Vodde was on hand to lead the discussion for the two-day event, which featured a mix of lectures, discussions, and participatory exercises designed to instill the values and philosophies of Scrum among the attendees.

Ronaldo Rebenque of US Autoparts (Philippines) remarked that the course was “very informational.” He added, “It gave me the know-how, tools, techniques, and concepts that I can use in future projects.” Butch Landingin, CTO of Orange & Bronze, also gleaned a lot of practical knowledge from the course. “Bas has a lot of practical experience with Scrum and he’s been sharing a lot of those stories. I found those stories to be the most valuable part of the course,” said Landingin. “We will be changing some of our company’s practices because of what we’ve learned in the course. “

Both professionals highly recommend the course to other companies. “I would definitely recommend the course to everyone in software development teams, not just the project leaders, but the developers, testers, analysts, architects,” said Rebenque. “Because Scrum is about self-managing teams, everybody will be responsible for managing their work.”

With the aim of promoting Agile practices in the local software industry, CodeLean is set to hold two more Scrum courses soon: the Product Owner’s Course in December or January, and another ScrumMaster Course in February. CodeLean has also sponsored an initiative named Agile Philippines.

CodeLean is a training and consulting services company that specializes in technical training and coaching in Agile methodologies, as well as provides consulting to companies who need to improve the efficiency and management of their IT department .

For more information about CodeLean, visit The Agile Philippines web site is located at

Friday, July 10, 2009

CodeLean to Hold 2nd ScrumMaster Certification Course in Makati

Encouraged by the success of the first-ever ScrumMaster Certification Course in the country, CodeLean, Inc. once again brings Dutch Agile expert Bas Vodde to Manila to head a two-day course on Scrum on September 3 to 4, 2009 at the Mezzanine of the Dusit Thani Hotel in Makati City. Scrum is an Agile methodology that deals with how projects are organized and planned.

The first ScrumMaster Course, held last April 14 and 15, was well attended, with a participant even flying in from Dubai to learn about Scrum. The course participants were very satisfied with what they learned from the course, and some are even planning on sending more of their colleagues to get ScrumMaster certification.

The Certified ScrumMaster course covers the theory and practice of the Scrum framework for product development. Further details about the course can be found at

Attendees who complete the course will receive an official certificate labeling them as Certified Scrum Masters (CSMs), and will be listed on the CSM registry of the Scrum Alliance, an organization of internationally recognized Scrum experts.

Returning to facilitate the course is Bas Vodde, who currently works for Odd-e, a Singapore-based consulting company that trains Asian professionals in Agile and Lean development. He is also coauthor of "Scaling Agile and Lean Development: Thinking and Organizational Tools for Large-Scale Scrum" and "Practices for Large-Scale Agile and Lean Development."

For inquiries and reservations, email or call (632) 8920419 and look for Andria Pasco or Irwin Torres.

Monday, April 20, 2009

CodeLean Holds the First ScrumMaster Certification Course in the Philippines

MANILA, PHILIPPINES -- CodeLean, Inc. recently held the Philippines’ first ever ScrumMaster Certification Course at Dusit Hotel in Makati City. The course was a success, with attendees from as far as Dubai, UAE flying in to participate. Dutch Agile expert Bas Vodde headed the two-day event, which was a mix of lectures, discussions, and participatory exercises designed to inculcate the values and philosophies of Scrum into the course attendees.

After attending the course, the participants were well-versed with both the theoretical and practical knowledge of Scrum—from the concepts and philosophies of Scrum down to the implementation and application of Scrum principles, as well as technical tips and advice for specific cases and situations.

With the conclusion of the course CodeLean CEO Ole Ronberg hopes that Agile practices will start to become more widespread in the Philippines’ software development industry. “We definitely plan to hold more local seminars and courses about Agile and Scrum in the future.”
Aside from the ScrumMaster Certification Course, CodeLean has also sponsored an initiative named Agile Philippines to promote the usage of Agile methods and practices in the country.

CodeLean is a software and Web development house that specializes in Agile development of software applications and web solutions, e-business solutions, and database-driven solutions. For more information about CodeLean, visit

Wednesday, April 1, 2009

Codelean Inc. Founds Agile Philippines

CodeLean promotes Agile and Scrum practices to local software companies

To promote the usage of Agile methods and practices in the Philippines, CodeLean, Inc. has sponsored an initiative aptly named “The benefits will be huge for the local IT sector if Agile practices are adopted here, with the country being one of the world’s top software outsourcing destinations,” says Peter Andersen, CodeLean Scrum Master. Studies have shown that Agile methods improve companies’ ability to respond quickly to market and customer needs, cut down on inefficiency, and make employees happier and more productive.

The Philippines’ First ScrumMaster Certification Course has hit the ground running by bringing in Dutch Agile expert Bas Vodde to head a two-day course on Scrum, an Agile methodology that deals with how projects are organized and planned. The course will be held in the Boardroom of the Dusit Hotel, Makati City on April 14 to 15, 2009. The Certified Scrum Master course covers the what, how, and whys of the Scrum framework for product development. The course will enlighten Filipino IT professionals about the theoretical and practical use of Scrum. Bas will conduct the course through stories and discussion, encouraging participants to actively learn by asking practical questions about how to apply Scrum in their particular situations.

“With this first big event, we hope that the movement gains momentum and starts to make Agile practices more widely used in the country,” says Ole Ronberg, CodeLean CEO. CodeLean is a Danish software company that specializes in Agile development of software applications and web solutions, e-business solutions, and database-driven solutions. The company’s highly-skilled team of programmers and project managers has extensive experience working professionally with Microsoft .NET technologies and uses the Scrum project management methodology to ensure the timely delivery of quality software products and advanced web solutions to clients. For more information about CodeLean, visit

For inquiries about the Certified ScrumMaster course, email or call us at +45 36 96 47 66 or our Philippine number at (632) 8920419.

About CodeLean
CodeLean is a young and dynamic company headquartered in Copenhagen, Denmark. The company was established in 2008 by passionate entrepreneurs with many years of experience in delivering quality IT solutions to clients in different industries. We specialize in Agile development of software applications and web solutions, e-business solutions, and database-driven solutions. Our approach allows clients to make changes to the requirements during the development process, and our transparent methods ensure that clients always have up-to-date information about their projects. For more information about CodeLean, visit


Welcome to Codelean's English blog. Here we will blog about events, news, software development, agile processes, Scrum etc.

We hope that you will enjoy our blog and encourage you to get in touch, if you feel that we are the kind of company that you could work with on your next .NET development project :-)