Page 133 - DCAP405_SOFTWARE_ENGINEERING
P. 133
Software Engineering
Notes mechanisms used to plug components together. The following design principles are
particularly relevant to parallel programming.
(e) Provide simple interfaces: Simple interfaces reduce the number of interactions that must
be considered when verifying that a system performs its intended function. Simple interfaces
also make it easier to reuse components in different circumstances. Reuse is a major cost
saver. Not only does it reduce time spent in coding, design, and testing, but it also allows
development costs to be amortized over many projects. Numerous studies have shown
that reusing software is by far the most effective technique for reducing software
development costs. As an example, a modular implementation of a climate modeling
system may define distinct modules concerned with atmosphere modeling, ocean modeling,
etc. The interfaces to each module can comprise a small set of procedures that access
boundary data, advance the simulation, and so on. Hence, there is no need for the user to
become familiar with the implementation of the various modules, which collectively
may comprise hundreds of procedures and tens of thousands of lines of code.
(f) Information Hiding: Ensure that modules hide information. The benefits of modularity
do not follow automatically from the act of subdividing a program. The way in which a
program is decomposed can make an enormous difference to how easily the program can
be implemented and modified. Experience shows that each module should encapsulate
information that is not available to the rest of a program. This information hiding reduces
the cost of subsequent design changes. For example, a module may encapsulate
related functions that can benefit from a common implementation or that are used
in many parts of a system,
functionality that is likely to change during later design or deployment,
aspects of a problem that are particularly complex, and/or
code that is expected to be reused in other programs.
Notes Notice that we do not say that a module should contain functions that are logically
related because, for example, they solve the same part of a problem. This sort of
decomposition does not normally facilitate maintenance or promote code reuse.
(g) Use appropriate tools: While modular designs can in principle be implemented in any
programming language, implementation is easier if the language supports information
hiding by permitting the encapsulation of code and data structures. Fundamental
mechanisms in this regard include the procedure (or subroutine or function) with its
locally scoped variables and argument list, used to encapsulate code; the user-defined
datatype, used to encapsulate data; and dynamic memory allocation, which allows
subprograms to acquire storage without the involvement of the calling program. These
features are supported by most modern languages (e.g., C++ , Fortran 90, and Ada) but are
lacking or rudimentary in some older languages (e.g., Fortran 77).
(h) Design checklist: The following design checklist can be used to evaluate the success of a
modular design. As usual, each question should be answered in the affirmative.
Does the design identify clearly defined modules?
Does each module have a clearly defined purpose? (Can you summarize it in one
sentence?)
126 LOVELY PROFESSIONAL UNIVERSITY