Interface Programming
Allowing classes to have intimate knowledge of each other goes against the basic principle of object-oriented programming. That principle states that you should try to decouple classes from one another as much as possible. If you don't, you run the risk of creating spaghetti code. To understand what is meant by spaghetti code, imagine a bowl of spaghetti where every noodle represents a different object. As you can see, each class (or noodle) touches quite a few other classes. Therefore, if you change one class, you must revisit, redo, and/or recompile every other class that it touches. That might not be a problem for a small project, but for large projects that need to be maintained, that would be a big problem. One way ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access