Modularity and Information Hiding in Program Design
Check out pages 145 to 146 in the book.
Jan 27, 2000
Procedural Abstraction
- When you organize a sequence of instructions into a named procedure to
perform an action.
Abstraction
- Separate the what from the how
- Ease of use
- Ease of modification
Abstract Data Types
- Isolate the data structure from its use.
- Key component in large scale software development.
Why data abstraction?
- Creating data should be separate from using data
- Users don't need to know details of data definition and manipulation
- Users only need to know what they can do to the data
What is an ADT?
- Definition of a data structure reflecting a real-world model.
- Definition of the operations allowed on that data structure such as:
- Ability to read and write the data structure as an operation
- Other operations may or may not be needed.
ADT operations.
- Defined as procedures or functions
- Must use parameters for all data passing
- User knows operation name and required arguments.
Information Hiding
- Ease of use
- Ease of modification
Encapsulation
- Keeps related content together
- Separates certain specified requirements from other parts of the
specification which may use those requirements.
Encapsulation from the terminology point of view
- this
"capsule" object is usually called a Class.
- The functions inside
the class are called private methods
- The data inside the
class are private variables
- The interface
functions for the outside world to your private methods are public methods.
- You can also have
public variables (The use of public variables is often considered to be a
bad habit).
Modularity
- Packages
- Import Statements
- Custom made
classes/packages