- when refactoring, we often end up in situation where single change causing cascading effects of changes and we retreat in our corner and cry, and recently, I have learned a good trick from J.B. Rainberger to introduce indirection layer to help us making small steps incrementally
- X minutes do
- It seems like OrderLines is a good home (domain concept) for Order.lines field, once you extract Order.lines into OrderLines, we could see a whole bunch of behavior should belong into OrderLines as well
- Setup
- checkout https://github.com/tonytvo/introduce-indirection-layer
- run tests, see them pass
- extract lines logic in class
Order
into methods - move lines into parameter object
OrderLines
- introduce lines into parameter objects for
asList
- introduce lines into existing parameter objects for
isEmpty
- introduce lines into existing parameter objects for
incrementItemQuantity(ItemAdded)
- move method into
OrderLines
- move method into
- introduce
orderLines
field fornew OrderLines(lines)
- inline
lines
field
- introduce lines into parameter objects for
tonytvo / introduce-indirection-layer Goto Github PK
View Code? Open in Web Editor NEWpractice introduce indirection layer
License: MIT License