Search This Blog

Friday, December 17, 2010

Agile Software Development Part 1: It's All in the Application Framework

Application frameworks such as Spring.NET and Unity (there are others however I have used these 2 with great success) will cost you a little time up front in learning them however they will save you a ton of time as you add more features to your application.  For many of you, this is not new and you're probably moving on to another blog but for some, it's a new concept.  Why, after all, would we want to use a 3rd party application framework at all?  It gets down to the old cliche of "not reinventing the wheel".  For an application of any size, there are going to be dependencies.  These dependencies can show up in the form of models, views, controllers, supporting classes, presenters, widgets, etc, etc.  In a well designed n-tier application, it is ideal to have these dependencies expressed in the form of explicit interfaces especially in components that cross boundaries.  By this, I'm referring to the definition of interfaces; the contracts that are guaranteed to be supported by any class that implements them (as opposed to the implicit interface which consists of all public method, properties and events).

This is where the application framework comes in.  Rather than having your class you just instantiated create instances of all of its dependencies, the framework can instead serve up your class to the context.  Fowler and others commonly refer to this as Dependency Injection.  For most basic needs Unity can provide ample support for dependency injection.  In many applications however, there will arise the need for things like custom factories where families of classes implement the same interface and are used at different times based on context.  If those types of needs arise, Spring.NET might be a better choice as it already has the built-in capabilities in the form of factory methods.  While you can achieve the same thing with Unity if you write extensions (at this time I'm referring to V1 not V2).

Likely, you'll also need support for things like logging and caching.  Again, both Unity and Spring can provide these either through dependency injection or through their AOP capabilities. 

If you are a steadfast Microsoft fan and use other capabilities like Enterprise Library, Unity will suit most of your needs.  If however, you are open to other frameworks, I highly recommend taking a peek at Spring.NET. In Spring's latest release, there is now support for ASP.NET MVC 2 as well as the Windows Communication Foundation API.  Previous support for ASMX services made it possible to create dynamic service proxies as well as services.  When consuming services there is often a need to transform messages from services to a model for the client to consume.  ASMX support was so well done, it was possible to share entities between service and client without the need for message transformation on the client side. Additionally, there is native support for NHibernate in Spring.NET. 

Before I end up sounding like I'm doing a comparison of the two, I'll stop.   The main takeaway for you should be to make it a Sprint Zero effort to compare the application frameworks out there, determine what your needs are then do a formal selection process to determine the best fit.  By all means though, shorten your project life-cycle and use an application framework.

Tuesday, December 14, 2010

Scrumgineering defined

Scrumgineering simply put is:
  "Practicing the craft of Software Engineering in a Scrum team". 

The rabbit hole goes much deeper though when we start talking about how to deliver quality software.  It takes a firm understanding of design principles, solution domain and especially various practices that ensure the delivery of quality software.  These various practices include but are not limited to: Unit Testing/TDD, Continuous Integration and Deployment Automation.


Unit Testing/TDD
In a world where the development iterations are short, QA will most likely find themselves receiving completed stories closer to the end of the sprint.  On the past 2 agile teams I've been a team member of, this has certainly been the case.  Since the collective goal of the team needs to be to carry little or no technical debt over to subsequent sprints, unit testing must be employed by the team's developers to minimize the footprint over which the QA team member(s) must test.  Testing all the non-visual aspects of the source code with unit tests ensures that QA can focus mainly on blackbox testing the features.  In a recent project, we even included a small test harness to allow our developers to execute queries against views and verify they met the global business requirements for queries (threshold on logical reads and on total execution time).  Test Driven Development can be used strategically to drive out a design when the problem domain isn't completely known/clear.  I still recommend a "Sprint Zero" to define high level architecture.

Continuous Integration
Taking advantage of build servers is equally important for 2 reasons.  First, it provides a sterile environment in which to execute the unit tests and helps us avoid the "But it works on my machine" mantra.  Second, it allows us to integrate the various components and run tests that are similar to unit tests but broaden the spectrum to encompass more than one class/component.  This second set of tests helps drive out problems with configuration and especially with deployments.

Deployment Automation
Deployment Automation is just that.  It means that we automate the configuration and installation of our application.  Most applications these days are web-based meaning there is typically no media to be circulated for clients.  Instead, the application is installed and configured on a web server or server farm.  ASP.NET applications make it relatively easy to deploy and in most cases can be done using XCOPY.  The challenge comes when moving from environment to environment (eg., Staging to Production).  Often, configuration differs greatly and managing configuration manually introduces major risk.  Taking advantage of the Continuous Integration servers mentioned earlier, it is relatively easy to set up an application's configuration and target a specific environment.  Most tools like MSBUILD and NANT provide an ample set of tasks that allow configuration settings to be changed on the fly.  Add-on tasks such as SDCTasks add even more functionality to the build engine (for MSBuild that is).

These practices coupled with Agile software development techniques (more to follow on this topic) will greatly improve overall software quality.

Friday, December 10, 2010

Unit Testing is not Important, It's Critical

I recall reading a paragraph in Kent Beck's book on Test Driven Development Test Driven Development: By Example in which he points out that developers end up writing almost twice as much as they would have written had they not used TDD to drive out the design.  This is most likely in the top 5 reasons why many teams and companies don't adopt TDD as a standard practice (aside from the paradigm shift TDD entails) although what isn't obvious is that the first releasable version of the code will most likely consist of far fewer lines of source code. 

There is a similar albatross hanging around the neck of teams who want to shore up QA efforts by writing unit tests.  In many eyes outside of the immediate team, it is simply perceived as writing more code than is necessary to solve the problem.  This mindset cannot be further from the truth.  As more and more companies start to adopt iterative approaches to software development, having developers write tests that exercise their code during the iterations is mission critical.  The manner in which code is written iteratively requires that top-down or bottom-up approaches to development be turned on their side.  Rather than fully completing the data access layer, iterative approaches require that UI, Business and Data Access all be written for a small vertical sliver of functionality.  This approach ultimately means that all layers are affected with each new feature.  Equally, the baseline architecture may also be affected with each new iteration. 

The end result is source code that is constantly in flux as it is being re-factored to add new functionality.  To battle this flux, we turn to unit tests.  If you are new to unit testing, think of it as non-visual code that executes the non-visual portions of the application.  Ultimately, this means that QA resources (which tend to be a scarce resource) need to focus only on exercising the application in the guise of the end user.  With unit tests shoring up their efforts, QA can do black box testing and ensure that the visual aspects of the system behave correctly.  Additionally, developers can be fairly certain that when a defect is found it is contained within a much smaller boundary (typically infrastructure for complex systems or maybe just in the integration between the visual layer and business layer). 

Iterative development does not have room for monumental efforts at the end of a release where thousands of bugs accumulated over each iteration are then resolved.  Defects need to be resolved as soon as they are discovered and the end goal needs to be discovering and resolving them DURING the iteration, not in some future iteration where the central focus is finding them. 

If there remains a doubt in your mind, contact me and I will make myself available online for a demonstration of just how effective unit testing can be in managing defects.