Define Interfaces
You may have noticed that all of the classes depend on concrete implementations. This isn’t a book on writing clean code, so I don’t want to go into too much detail, but relying on concrete classes leads to tight coupling between classes. This ultimately makes the code harder to work with, as a change in one class often directly impacts the class it depends on.
A common approach to breaking coupling between classes is to use and rely on interfaces instead of concrete implementations. For those not familiar, interfaces can be seen as defining a contract. They contain no logic; they just define the methods that a class must implement to fulfil that contract. At a code level, that means classes can depend on an interface rather ...
Get Creating Software with Modern Diagramming Techniques 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.