Testability > Reusability when writing code.
Reviewed points
- Testability > Reusability
- The cost to make a code reusable (general) enough is high
- Actually what we want is modularity, high cohesion, low coupling
- Very little code can be reuse four times, but we always need to test the code
- Design the code for test is more practical than design for reuse
- When to reuse?
- We still reuse the code if possible, but when?
- Micro answer
- Find module to use before coding a new one
- Refactor the code to make it reusable after we reuse it 3 or 4 times
- Refactor should be easy if the code is design for test
- Macro answer
- If the code widely reusable, make it as a library, a plugin or an application
- Let market to decide the economics of reusability
- If the code widely reusable, make it as a library, a plugin or an application
Review
It is a article explain the slide reviewed here. It explain the idea of the slide in a detail way. Quite good. For the macro answer of reusability, it looks not very practical for a developer.
It mentions a book named “Mythical Man Month”, it seems a good book.
Reference: Reuse Myth - can you afford reusable code?.