Published: 07 May 2010
By: Manning Publications

This article is taken from the book Brownfield Application Development in .NET. The authors define brownfield applications and discuss their three components - existing codebase, contamination by poor practices, and potential for reuse or improvement.

Contents [hide]

About the book

This is a sample chapter of the book Brownfield Application Development in .NET. It has been published with the exclusive permission of Manning.


Written by: Kyle Baley and Donald Belcham
Pages: 416
Publisher: Manning
ISBN: 1933988711

Get 30% discount

DotNetSlacker readers can get 30% off the full print book or ebook at www.manning.com using the promo code dns30 at checkout.

Introduction

An industrial brownfield is a commercial site contaminated by hazardous waste that has the potential to be reused once it's cleaned up. To a software developer, a brownfield application is an existing project, or codebase, that may be contaminated by poor practices, structure, and design, but that has the potential to be revived through comprehensive and directed refactoring.

Many of the established applications you'll encounter fit this description. By the time you start working on them, the core technology and architectural decisions have already been made, but architectures and technologies are still more easily repaired than replaced. In this article, we'll explore the various components of a brownfield application.

The components of a brownfield application are:

  • Existing codebase
  • Contamination by poor practices
  • Potential for reuse or improvement

Figure 1 shows the three components, which are interrelated.

Figure 1: Brownfield applications have three components that distinguish them from greenfield and legacy applications.

Brownfield applications have three components that distinguish them from greenfield and legacy applications.

It's easy to distinguish a brownfield application from a greenfield application. Greenfield applications have no previous project or technical history, whereas brownfield applications are typically burdened with it. Similarly, we make a distinction between brownfield and legacy applications as well. We'll come back to legacy codebases shortly, but for now consider them to be applications that are long forgotten and that are worked on only when absolutely necessary.

Brownfield applications generally fall between greenfield and legacy. Table 1 compares the three types of projects.

Table 1: A comparison of major project concerns and how they relate to greenfield, brownfield, and legacy applications

Concern

Greenfield

Brownfield

Legacy

Project state

Early in the development lifecycle; focuses on new features

New feature development and testing and/or production environment maintenance

Primarily maintenance mode

Code maturity

All code actively being worked on

Some code being worked on for new development; all code actively maintained for defect resolution

Very little code actively developed, except for defect resolution

Architectural review

Reviewed and modified at all levels and times as the codebase grows

Only when significant changes (business or technical) are requested

Rarely, if ever, reviewed or modified

Practices and processes

Developed as work progresses

Mostly in place, though not necessarily working for the team/project

Focused on maintaining the application and resolving critical defects

Project team

Newly formed group that is looking to identify the direction of its processes and practices

Mix of new and old, bringing together fresh ideas and historical biases

Very small team that maintains the status quo

In short, brownfield applications fall into that gray area between when an application is shiny and new and when it's strictly in maintenance mode. Now that we've provided the criteria for a brownfield application, let's examine the components from figure 1 in more detail.

Existing codebase

One of the defining characteristics of a greenfield application is that there's little or no prior work. There's no previous architecture or structure to deal with. By contrast, brownfield projects are ones that have a significant codebase already in place.

We don't mean that when you leave work after the first day, your greenfield application magically turns into a brownfield one overnight. Typically, it has been in development for some period of time (or has been left unattended) and now has some concrete and measurable work that needs to be done on it. Often, this work takes the form of a phase of a project or even a full-fledged project.

Your brownfield application may already be in production

Because you're dealing with an existing codebase, there's a chance it has already been released into production. If so, this will have some bearing on your project's direction but not necessarily on the techniques we'll talk about in this book. Whether you're responding to user requests for new features, addressing bugs in the existing version, or simply trying to complete an existing project, the methods in this book still apply.

There are a couple of points worth mentioning with respect to existing codebases, even if they're a little obvious:

  • You must have access to the code.
  • The code should be in active development.

These two points disqualify certain types of applications from being brownfield ones - for example, an application that requires occasional maintenance to fix bugs or add the odd feature. Perhaps the company doesn't make enough money on it to warrant more than a few developer hours a week, or maybe it's not a critical application for your organization. This application isn't being actively developed. It's being maintained and falls more into the category of a legacy application.

Instead, a brownfield codebase is an active one. It has a team assigned to it and a substantial budget behind it. New features are considered and bugs tracked.

The next component of a brownfield application is the degree to which it's contaminated. Let's see why this is an important aspect of the definition.

Contaminated by poor programming practices

Besides being an existing, actively developed codebase, brownfield applications are defined by their level of contamination, or smell - that is, how bad the code is. This determination is subjective in the best of cases but, in many instances, everyone agrees that something is wrong, even if the team can't quite put their finger on it or agree on how to fix it.

Different levels of contamination exist in any codebase. It's a rare application indeed that's completely free of bad code and/or infrastructure. Even if you follow good coding practices and have comprehensive testing and continuous integration, chances are you've accrued technical debt to some degree.

Technical debt

Technical debt is a term used to describe the quainter areas of your code. They're pieces that you know need some work but that you don't have the time, experience, or staff to address at the moment. Perhaps you've got a data access class with hand-coded SQL that you know is ripe for a SQL injection attack. Or each of your forms has the same boilerplate code cut and pasted into it to check the current user. Your team recognizes that it's bad code but isn't able to fix it at the moment.

It's akin to the to-do list on your refrigerator taunting you with tasks like "clean out the garage" and "find out what that smell is in the attic." They're easily put off but need to be done eventually.

The nasty side effect of technical debt is the bad design and code decisions. They're like the weekend you had that one time in college. It seemed like a good idea at the time, but now you constantly have to deal with it. In code, at some point you've made decisions about design and architectures that may have made sense at the time but now come back to haunt you regularly. It may now take an inordinate amount of time to add a new screen to the application, or it might be that you have to change something in several different places instead of just one. Like that weekend in college, these are painful, and regular, reminders of your past transgression. But unlike your college past, you can change code.

Along the same lines, contamination means different things to different people. You'll need to fight the urge to call code contaminated simply because it doesn't match your coding style.

The point is that you need to evaluate the degree to which the code is contaminated. If it already follows good coding practices and has a relatively comprehensive set of tests but you don't like the way it's accessing the database, you could argue that it isn't a full-fledged brownfield application - merely one that needs a new data access strategy.

Although it may be hard to pinpoint the exact degree of contamination, you can watch for warning signs that might give you a gut feeling:

  • How quickly are you able to fix bugs?
  • How confident do you feel when bugs are fixed?
  • How easy is it to extend the application and add new features?
  • How easy would it be to change how you log error messages in the application?

If your answer to any or all of these questions is a chagrined "Not very," chances are you have a lot of contamination.

Bear in mind that every application can be improved upon. Often, all it takes is a new perspective. And like any homeowner will tell you, you're never truly finished renovating until you leave (or the money runs out).

So far we've discussed the nature of the application and talked about its negative aspects. With the final core component of a brownfield application, we'll look at the positive side of things and see what can be done to make our app better.

Potential for reuse or improvement

The final criterion, potential for reuse or improvement, is important. It means that despite the problems you've identified, you're confident that the application can be improved. Your application isn't only salvageable but you'll be making an active effort to improve it. Often, it's an application that you're still actively developing (perhaps even still working toward version 1). Other times, it's one that has been put on hold for some time and that you're resurrecting.

Compare this with a traditional legacy application. Projects that have aged significantly or have been moved into maintenance mode fall into the legacy category. Such applications aren't so much maintained as they are dealt with. These applications are left alone and resurrected only when a critical bug needs to be fixed. No attempts are made to improve the code's design or to refactor existing functionality.

Note

In his book Working Effectively with Legacy Code (Prentice Hall PTR, 2004), Michael Feathers defines legacy code as any code that doesn't have tests. This definition works for the purpose of his book, but we're using a more traditional definition: really, really old code.

As you can see, it isn't hard to come up with an example of a brownfield application. Any time you work on an application greater than version 1.0, you're two-thirds of the way to the core definition of a brownfield application. Often, even applications working toward version 1.0 fall into this category.

Summary

In this article, we defined brownfield applications and showed how they compare with greenfield and legacy applications. We also discussed the three components of brownfield applications - existing codebase, contamination by poor practices, and potential for reuse or improvement - and how they interrelate.

Get 30% discount

DotNetSlacker readers can get 30% off the full print book or ebook at www.manning.com using the promo code dns30 at checkout.

<<  Previous Article Continue reading and see our next or previous articles Next Article >>

About Manning Publications

Manning Publication publishes computer books for professionals--programmers, system administrators, designers, architects, managers and others. Our focus is on computing titles at professional levels. We care about the quality of our books. We work with our authors to coax out of them the best writi...

This author has published 33 articles on DotNetSlackers. View other articles or the complete profile here.

Other articles in this category


Developing a Hello World Java Application and Deploying it in Windows Azure - Part I
This article demonstrates how to install Windows Azure Plugin for Eclipse, create a Hello World appl...
Android for .NET Developers - Building a Twitter Client
In this article, I'll discuss the features and capabilities required by an Android application to ta...
Ref and Out (The Inside Story)
Knowing the power of ref and out, a developer will certainly make full use of this feature of parame...
Developing a Hello World Java Application and Deploying it in Windows Azure - Part II
In this article we will see the steps involved in deploying the WAR created in the first part of thi...
Android for .NET Developers - Using Web Views
In this article, I'll show a native app that contains a web-based view. The great news is that HTML ...

You might also be interested in the following related blog posts


MSDN Guidance on ASP.NET MVC vs WebForms and its Impact on my EF + ASP.NET Work read more
Silverlight From Zero read more
WPF 4 (VS 2010 and .NET 4.0 Series) read more
View and print Reporting Services Reports from Silverlight. read more
How do I deploy an application and its prerequisites? (Mary Lee) read more
HealthVault 0908 SDK Highlights read more
Microsoft announced the beta release of IIS Application Warm-Up read more
Web Deployment Tool released to web (RTW) read more
My History of Visual Studio (Part 2) read more
Making your application sparkle with Windows 7 read more
Top
 
 
 

Please login to rate or to leave a comment.

Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.