Tuesday, September 25, 2012

SOLID advice from Telerik

The Telerik Blogs - Why SOLID Matters

One of the biggest struggles that developers have with adopting Unit Testing, whether it’s Test Driven Development (TDD), Behavior Driven Development (BDD) or even just Test Eventual Development (TED), is the difficulty some code is to test.  This is typically when code doesn’t follow the SOLID design principals. If you aren’t familiar with Robert C. Martin’s SOLID Principles, here is a quick summary.

There are five SOLID principals put forth by Robert (Uncle Bob) C. Martin.


Let’s talk about how SOLID can help make the day in the life of a .NET developer better.



What have we accomplished?  We changed our code so that it only does the one thing that is it supposed to, we removed the concrete implementation, and we injected our dependencies.  The code is still clean and concise, and pretty much the same number of lines that we had before the refactoring.

We are no longer dependent on the LoginService being implemented before we can test our code, get it checked in, and move on to the next feature request. We can test this code to make sure that it behaves as we expect, knowing that the dependencies won’t occlude the results.

Happy Coding!


While there's some Telerik stuff in this post, stating how their tools help in a given situation, it wasn't overly much and the great style and content outweighed the plugs my miles. We've all heard of SOILD, but the way Philip explains it in this article, with good examples and how it applies to the .Net Dev makes this article a keeper...

No comments: