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!

Kick It on DotNetKicks.com
Posted May 06 2008, 07:24 AM by bogardj

Comments

Neil Gibbons wrote re: PabloTV: Eliminating static dependencies screencast
on 05-06-2008 10:29 AM

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?

jdn wrote re: PabloTV: Eliminating static dependencies screencast
on 05-06-2008 10:48 AM

Nicely done.  Very useful.

Sean Chambers wrote re: PabloTV: Eliminating static dependencies screencast
on 05-06-2008 2:04 PM

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!

chadmyers wrote re: PabloTV: Eliminating static dependencies screencast
on 05-06-2008 4:37 PM

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.

Kevin Miller wrote re: PabloTV: Eliminating static dependencies screencast
on 05-06-2008 9:29 PM

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.

bogardj wrote re: PabloTV: Eliminating static dependencies screencast
on 05-06-2008 10:35 PM

@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.

David wrote re: PabloTV: Eliminating static dependencies screencast
on 05-12-2008 10:17 PM

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

Sean Scally wrote re: PabloTV: Eliminating static dependencies screencast
on 05-13-2008 12:37 PM

This is a great screencast. Thanks for making it.

Karl wrote re: PabloTV: Eliminating static dependencies screencast
on 05-18-2008 6:23 AM

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!

Colin Jack wrote re: PabloTV: Eliminating static dependencies screencast
on 05-21-2008 8:54 AM

Good stuff.

GrabBag wrote Separation of Concerns by example: Part 1
on 06-19-2008 10:12 PM

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

Richard wrote re: PabloTV: Eliminating static dependencies screencast
on 04-20-2009 6:40 AM

404 - original link seems to have gone down?

bogardj wrote re: PabloTV: Eliminating static dependencies screencast
on 04-20-2009 8:11 AM

@Richard

Whoops!  We moved servers and I guess some URLs got messed up.  Here's the new link:

http://pablotv.lostechies.com/

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Enter the numbers above:
Copyright Los Techies 2008, 2009. All rights reserved.
Powered by Community Server (Commercial Edition), by Telligent Systems