9 Make code reusable and generalizable
This chapter covers
- How to write code that can be safely reused
- How to write code that can generalize to solve different problems
Chapter 2 discussed how, as engineers, we often solve a high-level problem by breaking it down into a series of subproblems. As we do this on one project after another, we often find that the same subproblems come up again and again. If we or other engineers have already solved a given subproblem, then it makes sense to reuse that solution. It saves us time and reduces the chance of bugs (because the code is already tried and tested).
Unfortunately, just because a solution to a subproblem already exists, it doesn’t always mean that we can reuse it. This can happen if the solution ...
Get Good Code, Bad Code 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.