Beyond Classes: Packages

Classes are currently the best way for programmers to achieve modularity. But modularity is a big topic, and it extends beyond classes. Over the past several decades, software development has advanced in large part by increasing the granularity of the aggregations that we have to work with. The first aggregation we had was the statement, which at the time seemed like a big step up from machine instructions. Then came subroutines, and later came classes.

Cross-Reference

For more on the distinction between classes and packages, see "Levels of Design" in Key Design Concepts.

It's evident that we could better support the goals of abstraction and encapsulation if we had good tools for aggregating groups of objects. Ada supported the notion of packages more than a decade ago, and Java supports packages today. If you're programming in a language that doesn't support packages directly, you can create your own poor-programmer's version of a package and enforce it through programming standards that include the following:

  • Naming conventions that differentiate which classes are public and which are for the package's private use

  • Naming conventions, code-organization conventions (project structure), or both that identify which package each class belongs to

  • Rules that define which packages are allowed to use which other packages, including whether the usage can be inheritance, containment, or both

These workarounds are good examples of the distinction between programming in a language vs. programming into a language. For more on this distinction, see Program into Your Language, Not in It.

cc2e.com/0672

Cross-Reference

This is a checklist of considerations about the quality of the class. For a list of the steps used to build a class, see the checklist in "Chapter 9".

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.168.211