Unit - 3 (Part 1)
Unit - 3 (Part 1)
OBJECT DESIGN
COMBINING THREE MODELS
DESIGNING ALGORITHMS
Selecting Algorithms:
Selecting Data Structure:
Analysis Model
Now if there are 1000 students out of which only 10 students have skills for sports then for
finding sport-persons a simple loop will execute for 1000 times. This leads to inefficient
execution. To eliminate this problem some improvements can be made. For example, we can
create a hashed instead of unordered linked list. Another solution is to create index for
retrieving the objects that are accessed more frequently.
Referring to above example, if we want to find out the students who speak German and play
sport then we need to iterate through the number of students for many times. Naturally we
will get the less efficient model of execution. In order to improve the performance, we can
use the derived association. The derived association does not add useful information but is
used for fast access. Following figure illustrates this idea
Design Model
IMPLEMENTATION OF CONTROL
As part of the system design, the designer must implement state diagram of the dynamic
model. There are three basic approaches to implement it:
The definition of classes and operations can be adjusted to make the inheritance tree as
large as possible. It can be done in the following ways.
• Some operations may have fewer arguments than others. The missing arguments can
be supplied in the function definition and they may be ignored.
• Similar attributes in different classes may have the different names. These attributes
may be moved to a common ancestor class.
• Some operations may have fewer arguments because they are special cases of more
general arguments. These special operations can be implemented by calling the
general operations with appropriate parameters
• An operation may be defined on several different classes in a group but may not be
required in other classes. In that case the operation can be defined as a common
ancestor class and can be declared as no-operation on the classes that don’t care
about it.
OBJECT REPRESENTATION
The object designer has to choose when to use primitive types in representing the objects or
when to combine the groups of objects. A class can be defined in terms of other classes but
ultimately all data members have to be defined in terms of builtin data types supported by a
programming language. For example, roll no. can be implemented as integer or string. In
another example, a two dimensional can be represented as one class or it can be
implemented as two classes – Line class and Point class.
PHYSICAL PACKAGING
Modularity is the property of a system that has been decomposed into a set of cohesive and
loosely coupled modules. Modules serve as the physical containers in which we declare the
classes and objects of our logical designs. A module can be edited, compiled or imported
separately. Different object-oriented programming languages support the packing in different
ways. For example, Java supports in the form of package, C in the form of header files etc.
Modules are program units that manage the visibility and accessibility of names. Following
purposes can be solved by modularity.
A module typically groups a set of class definitions and objects to implement some service
or abstraction.
• Information Hiding
• Coherence of Entities
• Constructing Physical Modules
Information Hiding: During analysis phase we are not concerned with information
hiding. So, visibilities of class members are not specified during analysis phase. It is done
during object design phase. In a class, data members and internal operations should be
hidden, so, they should be specified as private. External operations form the interface so they
should be specified as public.
The following design principles can be used to design classes:
• A class should be given the responsibilities of performing the operations and proving
information contained in it to other classes.
• Calling a method of that class should access attributes of other class.
• Avoid traversing associations that are not connected to this class.
• Define interfaces at the highest level possible.
• External objects should be hidden. Defining interface classes could do this.
• Avoid applying a method to the result of another class unless the result class is already
a supplier of methods to the caller class.
Coherence of Entities: Module, class, method etc. are entities. An entity is said to
coherent, if it is organized on a consistent plan and all its parts fit together toward a common
goal.
Sr.
SA/SD OMT
No.
It clearly marks the system boundaries across System boundries can be easily
5 which software procedures should communicate extending by adding new objects,
with real world. It is difficult to extend boundries. relationships.