InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Temporary Code, Sustainable Code and Everything in Between

Posted by Vikas Hazrati on Mar 24, 2010

Sections
Process & Practices,
Architecture & Design,
Development
Topics
Delivering Quality ,
Code Analysis ,
Agile
Tags
Quality

There is code which is well tested, well re-factored and built to last. There is also code which is planned to be thrown away in a few days. Between these two extremes, there is a lot of gray area. The code in this gray area is written with the presumption that it would be cleaned up later, but then it is never done.

William Pietri analysed the cost associated with code from the viewpoint of a developer and a business person. According to William, code can be categorized into 3 broad categories.

  • Temporary - Code written with a plan to throw away in a short duration of time.
  • Sustainable - Code that’s built to last. Well factored, well understood by the team. It has strong automated tests and is not difficult to maintain.
  • Half-assed - Everything in the middle. Quick fixes that are never fixed and become permanent. Rush jobs.

William suggested that there is an  interesting part in the story. This is the difference in perception between developers and business people on the cost associated with the code. He gave the following comparison for associated cost

  businessperson developer

Temporary

low

low

Sustainable

high

medium

Half-assed

medium

high

Hence, the stakeholders are mostly happy with a half-assed option as it does not cost much and still delivers the value that they are looking for. This is where there is a huge mistake. According to William a better way to compare the code is by looking at the short term and long term costs irrespective of the role. According to him,

  short-term costs long-term costs
Temporary

low

low

Sustainable

high

medium

Half-assed

medium

high

The half-assed code eventually costs a lot higher and is detrimental to the business. On the other hand though the sustainable code might seem to be expensive at the start but eventually it is inexpensive over a longer run.

Of course, that’s not just bad for the developers. It’s bad for the company as a whole. If a company’s costs for software continuously increase, that eventually becomes a powerful advantage for competitors who are more thoughtful and disciplined about their approach to software development.

Commenting on the 3 categories, Alex Chaffee suggested that in his view Sustainable code = tests + half-assed code + refactoring. Likewise Chris Sterling agreed with William and commented that

High business expectations + Low engineering push-back = High technical debt which leads to Low engineering performance

Doing a similar analysis, Alberto Gutierrez suggested a different mechanism for looking at code. He rated the code from A to F based on combination of simplicity and extensibility. Simplicity defines the ease of understanding and reading the code. Extensibility defines the ease with which functionality can be added to the existing code. The range A-F defines the extremes between Excellent code and a code which needs to be started all over again.

The analysis again pointed to the fact that the best code would be both simple and extensible. This in turn, would map to the sustainable code category suggested by William.

So, how to avoid being in the gray?

According to William, stakeholder education on the long term implications of the type of code would help teams deliver business value. This would also help the teams avoid the technical debt trap. Once people are educated it would be easier to distinguish sustainable code from the one in the middle.

Most of the projects like that I’ve seen are really half-assed code that got sold as sustainable. Just as dangerous is the cowboy coder who rides in to save the day, but leaves a lot of half-assed code behind for other people to deal with.

 

  • This article is part of a featured topic series on Agile

Related Sponsor

In today’s hyper-competitive world, later may be too late to adopt Agile development and this Roadmap for Success will help you get started. Download "Agile Development: A Manager's Roadmap for Success" now!

Mark and Review by Markus W. Posted
  1. Back to top

    Mark and Review

    by Markus W.

    Usually before a task is completed in our project it has to be reviewed by another developer. Since we don't want to be too pedantic about code style, performance, etc. we decided that it's done as long as the requirements are met and a passing test exists
    (which is also important for the developer to stay successful).

    However there are some situations where the code is not ideal and then we are writing "Code Smell" markers an pin them to the wall. The team reviews them from time to time and decides if there is action (e.g. refactoring) required.

    I'm also marking code smells when I'm working on existing code, which is good if you don't have a review process.

    If you've reached the point when someone in your team tends to name the software as a code smell it's probably too late for improvement ;-)

Educational Content

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.