ELEMENTS OF OBJECT MODEL
Kinds of Programming Paradigms: According to Jenkins and
Glasgow, most programmers
work in one language and use only one programming style. They
have not been exposed to
alternate ways of thinking about a problem. Programming style is
a way of organizing programs
on the basis of some conceptual model of programming and an
appropriate language to make
programs written in the style clear.
There are five main kinds of programming styles:
1. Procedure oriented – Algorithms for design of computation
2. Object oriented – classes and objects
3. Logic oriented – Goals, often expressed in a predicate
calculus
4. Rules oriented – If then rules for design of knowledge base
5. Constraint orient – Invariant relationships.
Each requires a different mindset, a different way of thinking about the problem. Object
model is
the conceptual frame work for all things of object oriented.
There are four major elements of object model. They are:
1. Abstraction
2. Encapsulation
3. Modularity
4. Hierarchy
There are three minor elements which are useful but not essential part of object model.
Minor
elements of object model are:
1. Typing
2. Concurrency
3. Persistence
1.Abstraction:-
Abstraction is defined as a simplified description or specification of a system that
emphasizes
some of the system details or properties while suppressing others. A good abstraction is
one that
emphasizes details that are significant to the reader or user and suppresses details that
are, not so
significant, immaterial.
- Entity abstraction: An object that represents a useful model of a problem domain or
solution domain entity.
- Action abstraction: An object that provides a generalized set of operations all of which
program the same kind of function.
- Virtual machine abstractions: An object that groups together operations that are used
by
some superior level of control, or operations that all use some junior set of operations.
- Coincidental abstraction: An object that packages a set of operations that have no relation
to each other.
2.Encapsulation:-
The act of grouping data and operations into a single object.
Class heater {
Public:
heater (location):
~ heater ( ):
void turnon ( );
void turnoff ( );
Boolean ison () const
private:
3.Modularity:-
The act of partitioning a program into individual components is called
modularity. It is reusable
component which reduces complexity to some degree. Although partitioning a
program is
helpful for this reason, a more powerful justification for partitioning a program
is that it creates a
number of well-defined, documented boundaries within the program. These
boundaries, or
interfaces, are invaluable in the comprehension of the program
-
modules can be compiled separately. modules in C++ are nothing more than
separately
compiled files, generally called header files.
- Interface of module are files with .h extensions & implementations are
placed in files with
.c or .cpp suffix.
- Modules are units in pascal and package body specification in ada.
- modules Serve as physical containers in which classes and objects are
declared like gates in
IC of computer.
- Group logically related classes and objects in the same module.
- E.g. consider an application that runs on a distributed set of processors and
uses a message
passing mechanism to coordinate their activities.
- A poor design is to define each message class in its own module; so difficult
for users to find
the classes they need. Sometimes modularization is worse than no modulation
at all.
- Developer must balance: desire to encapsulate abstractions and need to
make certain
abstractions visible to other modules.
- Principles of abstraction, encapsulation and modularity are synergistic
4.Hierarchy:-
Hierarchy is a ranking or ordering of abstractions Encapsulation hides
company inside new of
abstraction and modularity logically related abstraction & thus a set of
abstractions form
hierarchy. Hierarchies in complex system are its class structure (the "is a"
hierarchy) and its
object structure (the "part of" hierarchy).
(a).Single Inheritance:-
Inheritance defines a relationship among classes. Where one classes shares structure or
behaviors
defined in one (single in heritance) or more class (multiple inheritance) & thus represents
a
hierarchy of abstractions in which a subclass inherits from one or more super classes.
Consider
the different kinds of growing plans we might use in the Hydroponics Gardening System.
An
earlier section described our abstraction of a very generalized growing plan. Different
kinds of
crops, however, demand specialized growing plans.
(b).Multiple Inheritance:-
Thank You