I regularly talk about Single Level of Abstraction SLA
with colleges. This example gives a few examples where SLA can or should be used.
- Code readability is much better
- Fewer LoC per function
- Less Comments needed (function names replace them)
- Less mental jumping between Levels (but now functions)
- Write Code top down
- Encapsulation
- Reusability of functions (e.g. -> Defeat() function)
- The
YoungHero
class will show code which has someSLA
issues and contains some comments what to refactor. - The
SeasonedHero
shows a refactored version.