Chapter 9Using Modules
Well-designed software is cohesive. Cohesion is when a piece of code is narrow, focused, and does one thing well. A good designer strives to achieve cohesion at all levels: functions, classes, and especially files.
A well-designed file should contain only things closely related to each other. Like things should be together in one file, and unlike things should be apart from each other in different files. In addition to making the code cohesive, small files focused on one particular concern also promote better reuse.
Nontrivial applications need many functions and multiple classes with intricate dependencies. Having the ability to access everything from everywhere leads to chaos, confusion, and errors. A piece of code ...
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