The Dangers of Single Responsibility in Programming

Let’s take a look at a possible system built for a company that sells a wide variety of products. This system was originally built around a Product object, and over the years the product object has continued to grow and acquire responsibility as new features were added to the system. The IProduct interface now looks like this:

The Template Pattern A Benevolent Dictator

This is an extremely useful pattern for avoiding code duplication and keeping code maintainable. As programmers we know that whenever we are copying and pasting the same, or nearly the same, logic across code we should really be encapsulating that code to prevent drift.

Refactoring Code: A Programmers Challenge Part 2

Well, at this point, his list of pages grown considerably. Rather than the handful we have in our code, we now need to hide the panel for many pages. As an additional requirement, it now needs be configurable too, so compiled code is not the best solution.

My two and a half cents – pitfalls with rounding

Bryant and I came a across an interesting issue when comparing two values that appeared identical, but which the code insisted were different. Our research lead us into the internals of ASP.Net rounding to solve an infrequent but legitimate concern.

The Power of Yield Return

While working on a project recently I ran into a problem that was very difficult to track down. We have a good number of checks that validate business rules on the main business object within the system. Sometimes these checks need to run on related business objects as well.

Code Camps this weekend!

There are two code camps this weekend:

CMAP Code Camp in Maryland
Pittsburgh Code Camp in Pennsylvania

I will be speaking at the Pittsburgh Code Camp on Refactoring – a topic that is very dear to me.
Register now and come along to talk code.
 
We are hiring!  Do you want to write beautiful code in a Test Driven, [...]

Don’t miss the Nova Code Camp South this weekend!

The NoVa CodeCamp South v1 will be held on March 29th 2008 in Woodbridge VA.  The speaker schedule has been posted here.
 
I am presenting two sessions:
9:00-10:15:     Refactoring in C#

1:00-2:15:        Web Application Testing in Watin

Register now!

 
We are hiring!  Do you want to write beautiful code in a Test Driven, Refactored, Agile .NET software company in the [...]

Can you find the bug in this code? (THE FIX)

Thanks to everyone for contributing!  It was really neat to read everyone’s ideas and see the discussion and review (talking about code is always fun!).  Here is a summary of responses and the “fixed” code. 
If you are interested in the original problem, go here.
 
@drakiula: The idea with the Response.Redirect is that it will stop [...]

Please question the need for whitespace

I have blogged about this before but I think it is a common problem that is worth restating since it affect developers across our industry.  I noticed the following method recently and again the curious separation of sections by whitespace popped into my head:

1: private void CalcHeaderOffsets()
2: [...]

NoVa CodeCamp South v1 speaking schedule has been announced!

The NoVa CodeCamp South v1 will be held on March 29th 2008 in Woodbridge VA.  The speaker schedule has been posted here.
I will be presenting on two topics:

Refactoring in C# – bad code to better code
Web Application Testing in Watin

There are lots of great sessions from WPF, TDD, SSIS, jQuery, SQL Server 2008 and [...]

Refactoring in C# at RockNUG this week

I will be giving a presentation on Refactoring in C# at RockNUG on Wednesday March 12th 2008 at 6:30pm.  Directions here.
What could be more fun on a Wednesday evening than critiquing some bad code and making it better? Come along to learn how to clean code like the Thycotic team. What do we [...]

What makes some code confusing?

Developers look at code for hour upon hour every day.  After some years of doing this, you can just look at something and almost intuitively understand what it is doing – assuming that some effort has been made by the developers to keep the code clear and understandable.  But every now and then, you find [...]

Speaking on Refactoring at RockNUG in March

I will be presenting on Refactoring in C# at the Rockville .NET User Group (RockNUG) on March 12th 2008 at 6:30pm.
Refactoring in C# – Bad code to better code What could be more fun on a Wednesday evening than critiquing some bad code and making it better? [...]

Removing dead code

What does your code terrain look like?  Are there bodies of dead logic lying here and there?  Maybe they helped briefly while you worked towards a better solution or perhaps they just fell victim to changing business rules.
At a recent Code Camp, there was a question about code generation and I answered that we [...]

Richmond Code Camp 3 reviewed

This last Saturday morning, the Thycotic team headed to Richmond at a bright and early 6am. This alone wouldn’t have been too bad but some on the team had been busy until 2am on a client project! For the first Richmond Code Camp ever, it actually didn’t rain (it rained all day for the [...]

Refactoring example in C# and VB.NET

Our very own Bryant Smith has revamped his conversion of Martin Fowler’s refactoring example (originally in Java) to nowcover both C# and VB.NET.
You can find the article here with the relevant downloads and walkthrough.
Martin Fowler’s example works nicely because it is a simple class structurethat is easy to understand. It alsohas enough complexity [...]

Whitespace is a code smell

Do you space out your code so there are line breaks between the pieces of logic? Whydo you think this isnecessary? Typically this is done to separate chunks of logic so that they can be easily distinguished. If it is a complicated enough chunk, then it may even make sense to put a comment at [...]

Syndicate this site using RSS The latest comments to all posts in RSS Subscribe in Google Reader
Furl It! Add to My MSN Digg It!