🎁 Get the FREE AI Skills Starter Guide β€” Subscribe β†’
BytesAgainBytesAgain
πŸ¦€ ClawHub

Dependency Breaking Technique Executor

by @quochungto

Select and execute the right dependency-breaking technique from Michael Feathers' catalog of 24 named techniques (Part III of Working Effectively with Legacy...

Versionv1.0.0
⚑ When to Use
TriggerAction
**Do not use** this skill for design-level refactoring after tests exist β€” these techniques are intentionally conservative and produce imperfect intermediate states. The goal is testability, not beauty.
This skill executes **Step 3 (Break Dependencies)** of the Legacy Code Change Algorithm.
---
πŸ’‘ Examples

Example 1: Parameterize Constructor (Java)

PaymentProcessor creates new DatabaseConnection("prod", 5432) in its constructor. Tests cannot run without a live database.

Technique: Parameterize Constructor. Add PaymentProcessor(DatabaseConnection db) constructor; original becomes this(new DatabaseConnection(...)). Tests inject new FakeDatabaseConnection(). Production callers unchanged.


Example 2: Extract Interface (Java)

UserNotifier holds a UserRepository field. Repository opens a database on construction; no way to substitute.

Technique: Extract Interface. Create empty IUserRepository; make UserRepository implements IUserRepository; change UserNotifier's field type. Compile β€” errors identify every method that must appear on the interface. Create FakeUserRepository for tests. Production unchanged.


Example 3: Push Down Dependency (C++)

OffMarketTradeValidator.showMessage() calls AfxMessageBox (Windows MFC) and g_dispatcher. Cannot test validation logic without the Windows GUI framework.

Technique: Push Down Dependency. Make showMessage() pure virtual in the base class. WindowsOffMarketTradeValidator holds real MFC code. TestingOffMarketTradeValidator overrides showMessage() with an empty body. Tests instantiate the testing subclass β€” validation logic is now testable without any UI framework. (See case study cs-012 in references/all-techniques.md.)


View on ClawHub
TERMINAL
clawhub install bookforge-dependency-breaking-technique-executor

πŸ§ͺ Use this skill with your agent

Most visitors already have an agent. Pick your environment, install or copy the workflow, then run the smoke-test prompt above.

πŸ” Can't find the right skill?

Search 60,000+ AI agent skills β€” free, no login needed.

Search Skills β†’