Skip to content
Refactoring: Invert Dependency With Observer | #53 episode artwork

May 8, 2020 10 min

Refactoring: Invert Dependency With Observer | #53

from PawCast with GeePaw Hill Hosted by GeePaw Hill

Another refactoring today: Use the observer pattern to invert an infelicitous dependency. In and of itself, this is a modest refactoring, but its smell often co-presents with others, and unravelling it all can be tricky. (Note: We aren't remotely done talking about first and second-order refactorings, there are plenty more to go. But I'm not writing a catalog, I'm working a project, so when a hefty one like this comes along, that's when I'm talking about it. You're gettin' em as I'm doin' em.) "Infelicitous dependency", eh? What could make a dependency an unhappy one? There are a lot of possibilities, but for me they usually amount to one of two cases: 1) an important abstraction is dependent on an unimportant detail, 2) it keeps me from writing a test I want to write. A concrete example might help, and I have just the infelicitous dependency we need for this, because it fits both bills, being both a "wrong direction" dependency and an inherently anti-testing class. Aren't we just terribly terribly lucky? --- You can read the full transcription of this podcast over on GeePawHill.org. Any feedback, you can always tweet @GeePawHill on Twitter, or drop a voice message via the voice messages link here on Anchor. If you are interested in becoming more involved in the Change-Harvesting community, click here to learn about GeePaw's Camerata.

Episode details come from the podcast's RSS feed.

Embed this episode

Ready to play

Refactoring: Invert Dependency With Observer | #53

0:00 10:44

No transcript yet.

Requests help us decide what to transcribe next.

Frequently asked questions

How long is this episode of PawCast with GeePaw Hill?

This episode is 10 minutes long.

When was this PawCast with GeePaw Hill episode published?

This episode was published on May 8, 2020.

Can I download this PawCast with GeePaw Hill episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.