8 API Design

When a block of code grows too complex, you should decompose it, as implied by figure 8.1. Chapter 7 discussed where to take things apart. In this chapter, you’ll learn how to design the new parts.

Images

Figure 8.1 Decompose a block of code into smaller blocks when it becomes too complex. How should the new blocks look? You’ll learn some principles of API design in this chapter.

You can decompose code in many ways. There isn’t a single correct way to do it, but there are more wrong ways than good ways. Staying on the narrow path of good API design requires skill and taste. Fortunately, the skill can be learned. Congruent with the theme ...

Get Code That Fits in Your Head: Heuristics for Software Engineering 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.