Lecture 1
1) Synopsis
Object oriented
development-modeling concepts – object oriented methodology models – object oriented themes
2) Target
At the completion of this lecture you should be able to
answer questions like
(a)
What is object-oriented methodology?
(b)
What are the models used by object oriented methodology?
3) Introduction
In this lecture, I will be discussing on
object oriented development, object oriented methodology, models and object
oriented themes. Also we will
see the object modeling and the concepts used for developing an object model.
In particular we will discuss on the following:
(i)
Object
(ii)
Object Oriented Approach
(iii)
Object Oriented Development
(iv)
OMT
4) Revision/Prerequisites
Please refer to pages 1 to 19.
5) Concepts
(i) Object
Data can be quantized into
discrete, distinguishable entities which are called objects.
*University question
a) Highlight the advantages of Object Oriented approach compared
to Procedure Oriented approach (4 marks) (B.Tech Degree Exam November 2005,
2002 Admissions).
b) List down the characteristics of objects. (4 marks)(B.Tech
Degree Exam June 2006, 2002 Admissions).
(ii) Object Oriented
Approach means organizing software as a collection of discrete objects that
incorporate both data structure and behavior.
(iii) Object
Oriented Development is a new way of thinking about software based on
abstractions that exist in the real world as well as in the program.
(iv) Object
Oriented Methodology is a methodology for object oriented development and a
graphical notation for representing objects oriented concepts. We can call this
methodology as OMT. The methodology has the following stages:
1. Analysis - An analysis model is a
concise, precise abstraction of what the desired system must do, not how it
will be done. It should not contain any implementation details. The objects in
the model should be application domain concepts and not the computer
implementation concepts.
2. System design - The designer makes
high level decisions about the overall architecture. In system design, the
target system is organized as various subsystems based on both the analysis
structure and the proposed architecture.
3. Object design - The designer builds
a design model based on the analysis model but containing implementation
details. The focus of object design is the data structures and algorithms
needed to implement each cycle.
4. Implementation - The object classes
and relationships developed during object design are finally translated into a
particular programming language, database, or hardware implementation. During
implementation, it is important to follow good software engineering practice so
that the system can remain the traceability, flexibility and extensibility.
The OMT methodology uses three kinds of models
·
Object Model-describes the static structure of
the objects in a system and their relationships. This model mainly contains
object diagrams.
·
Dynamic Model-describes the aspects of a system
that change over time. This model mainly contains state diagrams.
·
Functional Model-describes the data value
transformations within a system. This model contains the data flow diagrams
(v) Object Oriented Themes:
There are several themes in an object oriented
technology. These themes are not unique
to object oriented systems. We can see some important themes:
·
Abstraction-Abstraction consists of focusing on
the essential, inherent aspects of an entity and ignoring its accidental
properties. In system development, it focuses only on what an object is and
does, before deciding how it should be implemented.
·
Encapsulation- It can also be called as
information hiding. It consists of separating the external aspects of an
object, which are accessible to other objects, from the internal implementation
details of the object, which are hidden from other objects. It is not unique to
object oriented languages.
·
Combining Data and Behavior-The caller of an
operation need not consider how many implementations of a given operation
exist. Operator polymorphism shifts the burden of deciding what implementation
to use from the calling code to the class hierarchy. As an example, let us talk
about an object oriented program calling a draw procedure for drawing different
figures say a polygon, circle, or text. The decision of which procedure to use
is made by each object, based on its class.
·
Sharing- Inheritance of both data structure and
behavior allows a common structure and behavior allows common structure to be
shared among several similar subclasses without redundancy. The sharing of code
using inheritance is one of the main advantages of object oriented languages.
*University question
a) Give
examples for Multilevel and Multiple Inheritance. (4 marks)(BTech Degree Exam
Nov 2005, 2002 Admissions).
6) Summary
I think from the above you might have got
an idea about the basic concepts of object oriented development.
Lecture
2
1) Synopsis
Object Modeling– links and associations
– advanced links and association concepts
2) Target
At the completion of this lecture you should be able to answer questions
like
(a) What is an object?
(b) What are classes?
(c) What are object
diagrams?
(d) What is an
attribute?
(e) What is meant by
operations and methods in a class?
(f) What is a link, association,
multiplicity?
(g) Explain the
following link and association concepts:
(i) Link
attributes
(ii) Role
names
(iii)
Ordering
(iv) Qualifications
(v)
Aggregation
3) Introduction
. In lecture 1, we
discussed about Object oriented models, concepts, etc.In this lecture I will
discuss on object modeling and the concepts used for developing an object
model. In particular we will discuss on the following:
(v)
Objects
(vi)
Classes
(vii)
Object Diagrams/Class Diagram
(viii)
Attributes
(ix)
Operations/Methods
(x)
Link and association concepts
4)
Revision/Prerequisites
Please refer to pages 21 to 38.
5) Concepts
(I) Object Modeling: A
model is an abstraction of something for the purpose of understanding it before building it. It is easier to
manipulate than the original entity.
An object model captures the static
structure of a system, relationships between the objects, and the attributes
and operations that characterize each class of objects. This model is the most
important one. Some basic concepts covered in object modeling:
(a) Objects: We can define an object as a concept,
abstraction, or thing with crisp boundaries and meaning for the problem at
hand. All objects have identity and are distinguishable.eg:- Two apples can be
described as 2 different objects even though they have the same descriptive
properties.
(b) Classes: An ‘object class’ or ‘class’ describes a
group of objects with similar properties, common behavior, common relationships
to other objects, and common semantics.
Eg: -
Suppose you have a person class –you can term J S, M S, etc. to be objects of
that class.
(c)Object
Diagrams: They provide a formal graphic notation for modeling objects, classes
and their relationships to one another.
Fig.2.1
Classes and Objects
·
Class Diagram: It is a schema, pattern or
template for describing many possible instances of data.
·
An Instance Diagram describes how a particular
set of objects relate to each other. An instance diagram describes object
instances.
·
As the example above shows the symbol for an
object instance, while that of class diagram is a rectangle.
·
In the above example, JS , MS are
instances of class Person.
(d)Attributes:
An attribute is a data value held by objects in a class.
Eg: - In the
above example, Name, age, etc.of a person are attributes.
Attributes are
listed in the second part of the class box. So in the above example,
Fig.2.2
Attributes and values
(e)
Operations and methods: An operation is a function or transformation that may
be applied to or by objects in a class. Operations are listed in the lower
third of the class box.
Eg: - consider the above example, change –job and change-address on
Person class.
Fig.2.3 Operations
·
Each attribute name may be followed by
operational details, list of attributes and list of operations.
·
Each operation name may be followed by
operational details such as operational details such as argument list and
result type.
(f)Links and associations: They are used for
establishing relationships among objects and classes.
Link- A link is a physical or conceptual connection between object
instances .We can say that a link is an instance of an association.
Eg: - J S works for Simplex company.
Association
–Describes a group of links with common structure and common semantics’:- A
person works for a company.
They are inherently bidirectional. It means that a
binary association can be traversed in both directions. They are implemented as
pointers.
The below
figure shows a 1-1 association and corresponding links.
Fig.
2.4 Class Diagram
Fig.2.5 Instance Diagram
·
Multiplicity –specifies how many instances of
one class may relate to each instance of another class. The solid balls,”2+”
are multiplicity symbols. Associations may be binary, ternary or higher order.
Fig.2.6
Ternary associations and links
(g)Advanced
Link and Association Concepts:
i) Link
Attributes –A link attribute is a property of the links in an association. In
the below figure access permission is an attribute of ‘Accessible by’.
Fig.2.7 Link attribute for a
many-many association
* The OMT
notation for a link attribute is a box attached to the association by a loop
ii) Role names –
A role is an end of an association. Role name is a name that uniquely
identifies one end of an association.
Eg: - “Person
works for a Company.” Here the person plays the role of an employee and the
company the role of the employer.
Fig.2.8 Role names for an
association
iii) Ordering
-Sometimes, the objects are explicitly ordered. For example, the figure below
shows a workstation screen containing a number of overlapping windows. The
windows are explicitly ordered, so only the topmost window is visible at any
point on the screen.
Fig.2.9
Ordered sets in an association
iv)
Qualification – Qualifier is a special attribute that reduces the effective
multiplicity of an association. It reduces the effective multiplicity of an
association. We can qualify a one to many and many to many association.
For eg: - In the
below figure a directory has many files .A file may only belong to a single
directory. Within the context of a directory, the file name specifies a unique
file .A file corresponds to a directory and a file name.
Fig.2.10 A qualified association
(v) Aggregation: Aggregation is the “part-whole” relationship in which objects representing the components of something are associated with an object representing the entire assembly. The figure shows a portion of an object model for a word processing. Here a document consists of many paragraphs, each of which consists of many sentences.
Fig. 2.11 Aggregation
*University question
a) Explain
how to define role names and qualifications for associations. (B Tech Degree
Exam June 2006, 2002 Admissions).
b) With an
example, explain the Object Modeling Technique in detail.(12 marks). (B Tech
Degree Exam Nov 2005, 2002 Admissions).
c)
Explain: Aggregation, Generalization as extension and restriction use of
Metadata.(12 marks) .(B Tech Degree Exam Nov 2005,2002 Admissions).
6) Summary
The above lecture seems to have introduced you to
object modeling and the various notations used in it.
Lecture 3
1) Synopsis
Generalization and Inheritance - grouping constructs – a sample object
model
2) Target: At the completion of this
lecture you should be able to answer questions like (a) what is the concept of
generalization and inheritance.
(b) What are the
uses of generalization?
(c)
List the different grouping
constructs.
3) Introduction
In lecture 1, we discussed
about Object oriented models, concepts, etc.In lecture 2, a brief idea about
links, etc. were discussed. As stated above here I will be discussing on generalization
and inheritance in classes.
4) Revision/Prerequisites
Please refer to pages 39 to 45.
5) Concepts:
(i)
Generalization
and Inheritance: Generalization is the relationship between a class and one
or more refined versions of it. The class being refined is called the
‘superclass’ and each refined version are called a ‘subclass’. For example,
Equipment is the superclass of Pump and tank. Attributes and operations that
are common to a group of subclasses are attached to the superclass and shared
by each subclass. Generalization is sometimes called a ‘is-a’ relationship.
Each instance of a subclass is an instance of the superclass. The notation for
generalization is a triangle connecting a superclass to subclass.
Fig. 3.1 An inheritance
hierarchy
The
dangling ellipsis in the above figure indicates that there are additional
subclasses that are not shown in the diagram. This may be since there is no
room on the sheet and they are shown elsewhere or may be because enumeration of
subclasses is still incomplete. You can also see equipment type written next to
the triangle. This is called as a discriminator.
“A
discriminator is an attribute of enumeration type that indicates which property
of an object is being abstracted by a particular generalization relationship.”
What
is the use of generalization? Generalization is a useful construct for both
conceptual modeling and implementation.
Overriding Features:
I
think you are all familiar with this term. A subclass may override a superclass
feature by defining a feature with the same name. Here you can see that the
subclass feature refines and replaces the superclass feature. What is the need
for this feature? The reasons are many
·
to specify behavior that depends on the subclass
·
to tighten the specification of a feature.
·
better performance
Fig. 3.2 Inheritance for graphic
figures
In
the above figure, you can see that display must be implemented separately for
each kind of figure, although it is defined for any kind of figure.
(ii)
Grouping Constructs:
a)
Module- A module is a logical construct for grouping classes, associations, and
generalizations. It captures one view of a situation.
For
example: Let us say, electrical, plumbing, etc. are different views of a
building.
An
object model consists of one or more modules. Class names and association names
must be unique within a module. Module names are usually listed at the top of
each sheet. The same class may be referenced in many modules.
b)
Sheet- A sheet is a mechanism for breaking a large object model down into a
series of pages. A sheet is a single printed page. Each module consists of one
or more sheets.
Each
sheet has a title and a name or number. Each association/generalization appears
on a single sheet. Classes may appear on multiple sheets.
(iii)
Sample Model: For the sample model
you please look through the text book. It shows an object model of a
workstation window management system.
*University
question
a) Discuss
object model with features and diagrams (12 marks).(B Tech Degree Exam June
2006,2002 Admissions).
6) Summary
I think by now you will be able to develop the object model for any given
system.
7) Programming/Computational Assignments
i. For the diagram shown below write the name of each item in the box
Lecture 4
1) Synopsis
Advanced Object Modeling: aggregation – abstract classes
2) Target: At the completion
of this lecture you should be able to answer questions like (a) Compare aggregation with association
(b) Compare aggregation with
generalization
(c) What are recursive
aggregates?
(d) What is an abstract
class?
3) Introduction
In the previous lectures, we have covered the basics of object modeling,
now we will discuss on the advanced concepts used in object modeling. This will
be covered in the present lecture and also in the next lecture.
4) Revision/Prerequisites
Please refer to pages 57 to 62.
5) Concepts
(i)Aggregation –I think by now, all of you
know what is an aggregation? It is a strong form of association in which an
aggregate is made of components. Components are part of the aggregate.
·
Aggregation vs. Association –Aggregation is a
special form of association not an independent concept. If two objects are bound
by a part-whole relationship, it is an aggregation .If two objects are usually
considered independent, even though they may be linked, it is an association.
Some possible tests are:
i)
Would you use the phrase part of?
ii)
Are some operations on the whole automatically applied to its parts?
iii)
Are some attribute values propagated from the whole to all or some parts
iv)
Is there an intrinsic asymmetry to the association, where one object class is
subordinate to the other?
Fig.4.1
Aggregation and association
In
the figure, a company is an aggregation of its divisions, which in turns
aggregations of departments; a company is indirectly an aggregation of
departments.
The
decision to use aggregation is a matter of judgment and is often arbitrary.
·
Aggregation
vs. Generalization- Aggregation is not the same as generalization.
Aggregation relates instances .Two distinct objects are involved; one of them
part of other. While generalization relates classes and is a way of structuring
the description of a single object. With generalization, an object is
simultaneously an instance of the superclass and an instance of the subclass.
Aggregation
is called “a part of” relationship; generalization is often called “a kind of”
or “is-a “relationship.
Fig.4.2. Aggregation and generalization
The
above figure shows the aggregation and generalization in the case of a desk
lamp.
Aggregation
is sometimes called an “and-relationship” and generalization an
“or-relationship”.
·
Recursive
Aggregates Aggregation can be fixed, variable or recursive.
A fixed aggregate has a fixed structure; the number and types of
subparts are predefined. The desk lamp in figure 4.2 is a fixed aggregate.
A variable aggregate has a finite
number of levels, but the number of parts may Vary.The Company in Fig.4.1 is a
variable aggregate.
A recursive aggregate contains, directly
or indirectly, an instance of the same kind of aggregate; the number of
potential levels is unlimited.Fig4.3 shows a recursive aggregate.
Fig.4.3. Recursive Aggregates
·
Propagation of Operations-Propagation (also called
triggering) is the automatic application of an operation to a network of
objects when the operation is applied to some starting object.
For example, moving an aggregate moves its parts; the move operation propagates to the parts. The below figure
shows propagation.
Fig.4.4
Propagation of operations
Here, let us say a person owns multiple documents .Each document is
composed of paragraphs that are in turn composed of characters. The copy
operation propagates from documents to paragraphs to characters. It means that
by copying a paragraph, all the characters in it are copied. It does not
propagate in the reverse direction. The propagation is indicated with a small
arrow and operation name next to the affected association.
(ii)
Abstract Classes- An abstract class
is a class that has no direct instances but whose descendent classes have
direct instances.
A
concrete class is a class that is an instantiable; that is, it can have direct
instances. A concrete class may be leaf classes in the inheritance tree; only
concrete classes may be leaf classes in the inheritance tree. Now to get a
clear idea about look at the below figure.
Fig.4.5 Object model
defining abstract and concrete class
Fig 4.6
Concrete classes
All
the classes are concrete classes.
Fig.4.7
abstract class and abstract operation
6) Summary
Trying using these concepts in the previous
sample model.
.
Lecture 5
1) Synopsis
Generalization as extension and
restriction – multiple inheritance
2) Target
At the completion of this lecture you should be able to
answer questions like
(a)
Write notes on generalization as an extension and restriction.
(b)
What is multiple inheritance?
3) Introduction
In
the previous lectures we have already discussed the basics of generalization
and inheritance .Now to go into more
details about this.
4)
Revision/Prerequisites
Please refer to pages 63 to 69 of your textbook.
5) Concepts
(i)
Generalization as Extension and Restriction: By now you are all familiar
with what is meant by generalization.
In
generalization, an instance of a class is an instance of a class is an instance
of all ancestors of the class. Therefore you can say that all ancestor class
features must apply to the subclass instances. This includes not only the
attributes on the ancestor classes but also the operations on the ancestor
class.
A subclass may include many features, which is called as an extension. For example, fig.4.7 extends
class Employee with three subclasses that inherit all Employee features and add
new features of their own.
A
subclass may also constrain ancestor attributes. This is called restriction because it restricts the
values that instances can assume. For example, a circle is an ellipse whose
major and minor axes are equal.Arbitary changes to the attribute values of a
restricted subclass may cause it to violate the constraints, such that the
result no longer belongs to the original subclass. This is not a problem from
the perspective of the superclass because the result is still a valid
superclass instance. For example, a circle that is scaled unequally in the x
and y dimensions remains an ellipse but is no longer a circle.
*
The inherited features can be renamed in a restriction
For
example, the inherited features can be renamed the diameter.
Class
membership can be defined in two ways: implicitly by rule or explicitly by
enumeration.
Overriding Operations:
Overriding
is done for many reasons:
·
Overriding
for Extension: For example, suppose say you have a Window superclass and a
Window Labeled subclass. Now this superclass has draw operations that is used
to draw the Window boundary and contents. The subclass has an operation
draw-Labeled Window. The method could be invoked by invoking the method to draw
a window and then adding a code to draw the label.
·
Overriding
for Restriction: This is quite necessary when you have to keep the
inherited operations closed within the subclass. For example, the suprclass Set
may have the operation add(object).the subclass IntegerSet would then have the
more restrictive operation add(integer).
·
Overriding
for Optimization::
·
Overriding
for Convinience:
(ii) Multiple Inheritance: It permits a
class to have more than one superclass and to inherit features from all
parents. It rathers allows mixing of information from two or mores sources. Now
what is the advantage of multiple inheritance?
Well
it provides increased opportunity for reuse. And to speak about its
disadvantage, is a loss of conceptual and implementation simplicity.
Definition:
A
class may inherit features from more than one class. A class with more than one
superclass is called a join class. A feature from the same ancestor class found
along more than one path is inherited only once; it is the same feature.
Conflicts among parallel definitions create ambiguities that must be resolved
in implementation.
Fig.
Multiple inheritance from disjoint classes
Here in the above example, Amphibious Vehicle is a join class. If a class
can be refined on several distinct and independent dimensions, then use
multiple generalizations.
Accidental Multiple Inheritance
An instance of a join
class is inherently an instance of all the ancestors of the join class. For
example, an instructor is inherently both faculty and student. But suppose lets
say about a professor at HV taking classes at MIT.You can see there is no class
to describe the combination .This is a case of accidental multiple inheritance.
Fig.
Workaround for accidental multiple inheritance
6) Summary
Trying using these concepts in the previous sample model.
Lecture 6
1) Synopsis metadata – candidate keys –constraints.
2) Target
At the completion of this lecture
you should be able to answer questions like
(a) What is metadata?
(b)What are candidate keys?
(c) What are
constraints?
3) Introduction
In the previous lectures we have
already discussed the basics of generalization and inheritance .Now to go into
more details about this.
4) Revision/Prerequisites
Please refer to pages 69
to 77.
5) Concepts:
(i) Metadata-is data that describes other data.
For example, the definition of a class is metadata. Models are inherently
metadata, since they describe the things being modeled.
(ii)
Candidate Keys – It is a minimal set of attributes that uniquely identifies an
object or link. It means you can’t discard an attribute from the candidate key
and still distinguish all objects and links. A class or association may have
one or more candidate keys, each of which may have different combinations and
numbers of attributes. The object id is always a candidate key for a class. One
or more combinations of related objects are candidate keys for associations.
·
A candidate key is delimited with braces in an
object model.
Fig. Comparison of multiplicity
with candidate keys for binary associations
(iii)
Constraints: They are functional relationships between entities of an object
model.
6) Summary
So
that brings us to the end of the first module. All the concepts needed for
object modeling have been covered in the above lectures. In the next lectures
we will be covering on the other two models.
0 comments:
Post a Comment