5 Designing good abstractions
This chapter covers
- Understanding abstractions
- Adding abstractions in code
- Keeping abstractions simple
Good abstractions allow us to add new functionality to a system without constantly changing existing code. For example, think of a bookstore with a range of discounts like “Buy three books, get one free,” “45% off during Christmas,” and “Buy five e-books, get one printed copy free.” The marketing team proposes new discounts regularly, so the development team needs an easy way to add them to the code. A well-designed software system will have abstractions in place so developers can add new discounts with minimal effort.
It’s difficult to define what abstractions are in one sentence, so I’ll use a few:
-
They describe ...
Get Simple Object-Oriented Design now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.