Chapter 9. Changing the behavior of services

This chapter covers

  • Changing behavior without changing code
  • Making behaviors configurable and replaceable
  • Introducing abstractions to allow for composition and decoration
  • Avoiding inheritance for overriding object behaviors
  • Making classes final and methods private to prevent object abuse

You can design your services to be created and used in certain ways. But the nature of a software project is that it will change over time. You’ll often modify a class in such a way that, when it’s used, it will behave the way you want it to. However, modifying a class comes with a cost: the danger of breaking it in some way. A common alternative to changing a class is to override some of its methods, but this can ...

Get Object Design Style Guide 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.