in

 

Jimmy Bogard

Assistant to the assistant to the regional manager

PabloTV: Eliminating static dependencies screencast

Nature abhors a vacuum.  It turns out she also abhors static dependencies (I have my sources).  Static dependencies are the modern-day globals, often exposed through classes named "Helper".  I've certainly been guilty of overusing static dependencies in the past, with classes like "LoggingHelper", "SessionHelper", "DBHelper" and so on.

The problem with static dependencies is that they are opaque to the extreme, enforcing a strong coupling that is impossible to see from users of the class.  To demonstrate techniques for eliminating static dependencies, Ray Houston and I created a short screencast:

Eliminating static dependencies screencast

Our screencast demonstrates using TDD along with ideas and techniques laid out in Michael Feathers' Working Effectively with Legacy Code and Joshua Kerievsky's Refactoring to Patterns.  It details how to make safe, responsible changes to an existing legacy codebase, while improving the design by breaking out dependencies to a static class.

Hope you enjoy it!

Comments

 

Neil Gibbons said:

Great stuff!

As a developer keen to improve how I wrote code, actually seeing the theory put into action is a great help.

More I say ... more!

P.S.

Is that case statement a candidate for a Strategy pattern?

May 6, 2008 10:29 AM
 

jdn said:

Nicely done.  Very useful.

May 6, 2008 10:48 AM
 

Sean Chambers said:

Bravo!

Well done gentlemen. This motivates me to do one next time. After my honeymoon I will see about doing a screencast. I do them for guys here in the office when dealing with training them on various pieces of software so I would like to try one for lostechies.

good job again!

May 6, 2008 2:04 PM
 

chadmyers said:

Great job guys!  Thanks for the time and effort involved in this.  I especially like how you kept it short, sweet, and packed with info.

May 6, 2008 4:37 PM
 

Kevin Miller said:

Great job. Thanks for the time and effort it took to put that together. I enjoyed the example project. That code looks familiar somehow.

I was sitting there drinking Miller Lite and screaming  "Hit Ctrl+Alt+V to declare the variable! Dammit , nooo! use F6 to move the class to the outer scope!"

But then I realized that you were keeping it simple to avoid confusion.

May 6, 2008 9:29 PM
 

bogardj said:

@Kevin

ACTUALLY

You can blame Ray on this one.  He uses the "Visual Studio" R# shortcuts, while I use "IntelliJ" R# shortcuts.  Like a pilot climbing into a fighter jet only to notice all the controls got moved around.

May 6, 2008 10:35 PM
 

David said:

Great screencast, thanks a lot!

Related to @Neil's comment about the strategy pattern, a nice candidate for your next screencast (hope there's a next one :)) might be to factor out that switch statement to make it easier to add payment types and payment type logic in future. I'd be keen to see that, especially how you use tests to drive your design decisions.

Regards,

David

May 12, 2008 10:17 PM
 

Sean Scally said:

This is a great screencast. Thanks for making it.

May 13, 2008 12:37 PM
 

Karl said:

Very good screencast! I will present it to my dev-team (10 people) next week. It's really an eye-opener, even if you have read Michael Feathers Book, it's always good to see these techniques in practice. I'd like to see more of this stuff, maybe some refactoring to patterns stuff, like introducing strategy objects instead of switch statements, etc...

Keep on doing this great work. Your site and codebetter are my favorite blogging sites!

May 18, 2008 6:23 AM
 

Colin Jack said:

Good stuff.

May 21, 2008 8:54 AM
 

GrabBag said:

In the prelude to this series, I looked at a snippet of code that took the kitchen sink approach to concerns

June 19, 2008 10:12 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About bogardj

I'm a senior consultant with Headspring Systems in Austin, TX. My focus is using .NET technologies together with Agile methodologies. Back in 2005, I drank the Agile punch and haven't looked at a waterfall the same since.
Copyright Los Techies 2007. All rights reserved.
Powered by Community Server (Commercial Edition), by Telligent Systems