Chapter 4: Seam Model
Place where you can alter behaviour in your program without editing in that place.
Main usage: to cut dependency
Type of Seams
- Preprocessing Seams: example C++ macro
- Link Seams: example python mock
- Object Seams: implement interface, then change the object
Chapter 6: I Don’t Have Much Time and I Have to Change It
Sprout method
- Create a separate function and just call that function from the main method
- At least that function can be tested
Sprout class
- Similar with sprout method (but create a new class), when you need to modify a class, but the class not easily instantiated (because of a lots of dependency)
- Cons: gut the abstractions, since the main purpose is just to put something under test
Wrap method
- Either:
- Rename the old method and wrap it with a new method with the same name with the old one, and create a new method (that can be tested) and call it before/after the old renamed method is called, or
- Create a new method that call the old method, the new method can be added things (e.g. new method that can be tested) on after/before the old method is called