Program Design With Modules and Oops
Program Design With Modules and Oops
Modular programming is a software design technique that increases the extent to which software is
composed of separate, interchangeable components, called modules by breaking down program
functions into modules, each of which accomplishes one function and contains everything necessary to
accomplish this. Conceptually, modules represent a separation of concerns, and improve maintainability
by enforcing logical boundaries between components. Modules are typically incorporated into the
program through interfaces. A module interface expresses the elements that are provided and required
by the module. The elements defined in the interface are detectable by other modules. The
implementation contains the working code that corresponds to the elements declared in the interface
The basic idea underlying modular design is to organize a complex system as a set of distinct
components that can be developed independently and then plugged together. Although this may appear
a simple idea, experience shows that the effectiveness of the technique depends critically on the
manner in which systems are divided into components and the mechanisms used to plug components
together. The following design principles are particularly relevant to parallel programming.
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.
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.
Use appropriate tools.
Object-oriented programming
Abstraction
In computer science, abstraction is the process by which data and programs are defined with a
representation similar to its meaning (semantics), while hiding away the implementation details.
Abstraction tries to reduce and factor out details so that the programmer can focus on a few concepts at
a time. A system can have several abstraction layers whereby different meanings and amounts of detail
are exposed to the programmer. For example, low-level abstraction layers expose details of the
hardware where the program is run, while high-level layers deal with the business logic of the program.
In computer programming, abstraction can apply to control or to data: Control abstraction is the
abstraction of actions while data abstraction is that of data structures.
Encapsulation
Encapsulation means that the internal representation of an object is generally hidden from view outside
of the object's definition. Hiding the internals of the object protects its integrity by preventing users
from setting the internal data of the component into an invalid or inconsistent state. A benefit of
encapsulation is that it can reduce system complexity, and thus increases robustness, by allowing the
developer to limit the interdependencies between software components.
Message passing
Message passing in computer science is a form of communication used in parallel computing, object-
oriented programming, and inter process communication. In this model, processes or objects can send
and receive messages to other processes. By waiting for messages, processes can also synchronize.
Message passing is the paradigm of communication where messages are sent from a sender to one or
more recipients. Forms of messages include method invocation, signals, and data packets.
Modularity
Modular programming is a software design technique that increases the extent to which software is
composed of separate, interchangeable components, called modules by breaking down program
functions into modules, each of which accomplishes one function and contains everything necessary to
accomplish this.[1] Conceptually, modules represent a separation of concerns, and improve
maintainability by enforcing logical boundaries between components. Modules are typically
incorporated into the program through interfaces.[2] A module interface expresses the elements that are
provided and required by the module. The elements defined in the interface are detectable by other
modules. The implementation contains the working code that corresponds to the elements declared in
the interface.
Polymorphism
Polymorphism is the ability to create a variable, a function, or an object that has more than one form.
The purpose of polymorphism is to implement a style of programming called message-passing in the
literature in which objects of various types define a common interface of operations for users. Operator
overloading of the numeric operators (+, -, *, and /) allows polymorphic treatment of the various
numerical types: integer, unsigned integer, float, decimal, etc; each of which have different ranges, bit
patterns, and representations. Another common example is the use of the "+" operator which allows
similar or polymorphic treatment of numbers (addition), strings (concatenation), and lists (attachment).
This is a lesser used feature of polymorphism.
Inheritance