Escolar Documentos
Profissional Documentos
Cultura Documentos
Software developed will be a best one if all these elements were understood and
handled properly. Else this complexity will result in projects that are
- Late
- Over Budget
- Deficient (lack) in their requirements
This process of developing software that is late, over budget and deficient in
requirements is called as Software Crisis. Solution to solve the Software crisis
problem is Decomposition (Divide and Conquer). It means
- Decompose the system into various modules
- Analyze, design and implement these modules individually
- Then integrate all these individual modules to get the overall
system
Types of Decomposition
1) Algorithmic Decomposition
Each module in the system denotes a major step in some overall process
- Used in Structured/Top-Down Approach
- Difficult to reuse
2) Object Oriented Decomposition
- Decomposing the system according to the key abstractions (classes
and objects) in the system
- It is a Bottom-up Approach
- Reusability is highly ensured
- Better to go for Object oriented than algorithmic decomposition.
Major Elements:
1) Abstraction
- A good abstraction is one that emphasizes details that are
significant to the user and suppresses details that are atleast for the moment
immaterial.
- It denotes the essential characteristics of an object that distinguish
it from all other kinds of objects.
- Example:
Any class is an example of abstraction.
2) Encapsulation
- Encapsulation is the process of compartmentalizing the elements of
abstractions (data members and member functions) that constitute its structure
and behavior
- Encapsulation protects the data from corruption
- Example:
Any class is an example for encapsulation.
3) Modularity
- It is a way of developing the systems architecture.
- It is defined as the property of the system that has been
decomposed into a set of cohesive and loosely coupled modules
- Example:
The java programs are modularized in the form of Packages
(Collection of classes)
4) Hierarchy
- It is the process of ranking or ordering the abstractions (classes &
objects)
- An object-oriented system organizes classes into subclass-super
hierarchy.
- At the top of the hierarchy are the most general classes and at the
bottom are the most specific
- A subclass inherits all of the properties and methods (procedures)
defined in its superclass.
Example:
M o to r V e h ic le
B us T ru c k C ar
- Inheritance is a relationship between classes where one class is the parent class
of another (derived) class.
- Inheritance allows classes to share and reuse behaviors and
attributes
- The real advantage of inheritance is that we can build upon what
we already have and,
- Reuse what we already have
Types of Inheritance:
Single, Multiple, Hybrid, Multi level..
Example:
Multiple Inheritance:
For example utility vehicle inherents from Car and Truck classes
MotorVehicle
UtilityVehicle
Minor Elements:
1) Typing
- It is the enforcement of the class of an object, such that objects of
different types may not be interchanged, or at the most, they may be interchanged
only in very restricted ways.
Examples of Typing:
- Strong/Weak Typing:
- A given programming language may be strongly typed,
weakly or untyped
- eg: int a; float b=10.0;a=b;
- Eiffel is a strongly typed language that it does not accept the
above conversion from float to int.
- Smalltalk, C++ is an untyped language where it truncates the
decimal value any assigns integer 10 to variable ‘a’
Strong Typing:
- In strongly typed languages, the type conformance is strictly enforced.
- The violations are known at the compile time itself.
Weak Typing:
- In Weakly typed languages, the type conformance is not strictly enforced.
- The violations are known only at the run time.
Another example of typing is Static/Dynamic binding:
- Binding is the time the variable are bound to types
- Static binding is the types are bound to variable at compile time itself.
- Example: ‘C’ language supports static binding
-Dynamic binding is the types are bound to variable at run time itself.
- Example: ‘C++’ language supports dynamic binding
2) Concurrency
- It is the property that many objects act at the same time.
- ie more than one processes are executed at the same time
(concurrently)
- It is achieved in JAVA through multi-threading concept
3) Persistence
- Objects have a lifetime.
- An object can persist beyond application session boundaries,
during which the object is stored in a file or a database, in some file or database
form.
- It saves the state and behavior of an object across time and space.
Objects:
- Objects are defined as any tangible and/or visible entity in this real world
that exhibits some well defined properties and behavior.
- It is an instance of a class.
- An object possess state, behavior and identity
State of an object:
- State represents all of its both static as well as dynamic properties
- Example:
Attributes describe objects states.
-In the Car example the car’s attributes are:
- Color, manufacturer, cost, owner, model..
Identity of an object:
- Property that distinguishes an object from all other kinds of objects.
- It gives a unique identification to the object
Behavior of an object:
- Behavior is how an object acts/reacts in terms of its state (properties)
changes
- It is nothing but the operations performed by the object.
Example:
- Methods define objects behavior and specify the way in which an
Object’s data are manipulated.
- In the Car example the car’s methods are:
- drive it, lock it, tow it, carry passenger in it.
Types:
- Modifier: operations that alters the state of the object
- Selector: operations that access the selected state of the object and do not
change it.
- Iterator: operations that access the state of the object in a well defined
order and do not change it.
- Constructor: operation that initializes the state of the object
- Destructor: operation that free the memory allocated to the object
Types of object:
- There are two types of objects. They are
Active objects and Passive objects
An active object is one that encompasses its own thread of control. An active
object is autonomous (ie) they exhibit some behavior without being operated
upon by another object.
A passive object is one that does not encompass its own thread of control.
They exhibit some behavior when explicitly being operated upon by another
object
Example:
Main object (active object)
Object2
: Pilot
: Planes
Visibility:
If one object wants to send a message to other object means only if there
are visible to each other. ie either of 4 cases must satisfy for visibility.
1) Supplier object is global to client
2) Supplier object is a parameter to some operations of the client
3) Supplier object is part of the client object
4) The supplier object is a locally declared object in some operations of the
client
Aggregation
It represents a whole/part relationship.
It is a specialized kind of association in which one object represents a
whole thing and other represents part of the whole.
:CAR
:ENGINE :WHEEL
:SEAT
Class:
- Implementation:
It is the inside view of the class
Implementation of all of the operations defined in the
interface of the class
E m p l o y e e
n a m e
a d d r e s s
s a l a r y
S S #
O f f i c e W o r Mk e ar n a g eP r r o d u c t i o n W o r
d a t a E n t r y d a t a E n t r y d a t a E n t r y
C o m p u t e P a y C r o o l m l p u t e P a y Cr o o l ml p u t e P a y r o l l
p r i n t R e p o r t p r i n t R e p o r t p r i n t R e p o r t
Association :
1) cardinality
It defines how many occurrence/instance of one class is related to
how many occurrence/instance of another class.
It is also called as multiplicity.
There are different kinds of cardinality exists. They are
One to One
One to Many
Many to One
Many to Many
2) Association role
Role played by the classes in the relationship is placed at the end of
the relationship.
3) Navigability
This gives the direction in which the relationship is read out.
Example:
m 1
Person Company
employer employee
Aggregation:
Example:
has
TEAM PLAYERS
Using:
• A special form of association is a client-server relationship called using
relationship.
• This relationship can be viewed as one-way interaction i.e. one way
navigability exists among the classes where one class (client) requests the
service of another class (server).
Example:
Instantiation:
Example:
Item Integer
Queue IntegerQueue
Meta-Classes
A Meta class is a class whose instances are also classes. They are
supported in smalltalk. The primary purpose of metaclasses in smalltalk is
to provide the class variable i.e. static variables that is common to all the
objects.