Lessons In MSBuild – Applying the Single Responsibility Principle to MSBuild Projects

August 23, 2009

As an experienced developer, I promote the use of good practices in object oriented designs.

I was modifying a number of MSBuild and TFS Build project files for several related environments and I noticed that they both duplicated information and each had more than one responsibility – such as specifying the solution to build and compilation settings such as code analysis, configuring testing, and then perhaps performing some custom operations.

I wondered if I could apply the Single Responsibility Principle to the build project files.

Indeed, you can split your project files into multiple files, and from the main project you can import the other file by using the following syntax.

<Import Project="MyCommonTargets.proj" />


SOLID Principles

July 22, 2009

In a previous posting on BDD,  I quickly referenced ‘Uncle Bob’ Robert C. Martin’s website where he outlines the SOLID Principles.

I wanted to expand upon that and provide a few more helpful links.

The best examples I have seen that demonstrates these principles can be found in a series of short videos on DimeCasts.net.

# 88 – Creating SOLID Code: Single Responsibility Principle (SRP)

# 90 – Creating SOLID Code: Open/Closed Principle (OCP)

# 92 – Creating SOLID Code: Liskov Substitution Principle

# 94 – Creating SOLID Code: Interface Segregation Principle

# 96 – Creating SOLID Code: Dependency Inversion Principle

 

Scott Hanselman too has a number of podcasts where he is directly interviewing ‘Uncle Bob’:

Hanselminutes Podcast 145 – SOLID Principles with Uncle Bob – Robert C. Martin

When I listened to this podcast, I was quite pleased to hear and have my personal experience validated when ‘Uncle Bob’ rated the Single Responsibility Principle as the most important. In my personal experience, and in the experience of a number of my colleagues, this principle alone has had the largest positive effect in the quest to write cleaner and more intuitive code.

Hanselminutes Podcast 150 – Uncle Bob Martin, this time with feeling

And a more recent podcast discussing the related topic of professionalism.

Hanselminutes Podcast 171 – The Return of Uncle Bob


Follow

Get every new post delivered to your Inbox.