Professional Documents
Culture Documents
3.object Oriented
3.object Oriented
AND DESIGN
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 3
Brindavan College, Bangalore
OBJECT ORIENTATION?
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 4
Brindavan College, Bangalore
Identity
• Identity means that data is quantized into discrete, distinguishable
entities called objects. E.g. for objects: personal computer, bicycle,
queen in chess etc.
• Objects can be concrete (such as a file in a file system) or
conceptual (such as scheduling policy in a multiprocessing OS).
Each object has its own inherent identity. (i.e. two objects are
distinct even if all their attribute values are identical).
• In programming languages, an object is referenced by a unique
handle.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 5
Brindavan College, Bangalore
Inheritance
• It is the sharing of attributes and operations (features) among
classes based on a hierarchical relationship. A super class has
general information that sub classes refine and elaborate.
• E.g. Scrolling window and fixed window are sub classes of
window.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 6
Brindavan College, Bangalore
Polymorphism
• Polymorphism means that the same operation may behave
differently for different classes.
• For E.g. move operation behaves differently for a pawn than for
the queen in a chess game
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 7
Brindavan College, Bangalore
OO DEVELOPMENT
• Development refers to the software life cycle: Analysis, Design and
Implementation.
• The essence of OO Development is the identification and
organization of application concepts, rather than their final
representation in a programming language.
• OO development is fundamentally a way of thinking and not a
programming technique.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 8
Brindavan College, Bangalore
OO methodology
• System conception
• Analysis
• Domain Model
• Application Model
• System Design
• Class Design
• Implementation
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 9
Brindavan College, Bangalore
Three models
• Class Model - for the objects in the system & their relationships. It
describes the static structure of the objects in the system and their
relationship.
• State model - for the life history of objects. It describes the
aspects of an object that change over time. It specifies and
implements control with state diagrams-a graph whose nodes are
states and whose arcs are transition between states caused by
events.
• Interaction Model - for the interaction among objects. It describes
how the objects in the system co-operate to achieve broader
results. This model starts with use cases that are then elaborated
with sequence and activity diagrams.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 10
Brindavan College, Bangalore
OO THEMES
1. Abstraction
2. Encapsulation (information hiding)
3. Combining data and behaviour
4. Sharing
5. Emphasis on the essence of an object
6. Synergy
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 11
Brindavan College, Bangalore
MODELLING AS A DESIGN
TECHNIQUE
• MODELLING
Testing a physical entity before building it
Communication with customers
Visualization
Reduction of complexity
• ABSTRACTION
Abstraction is the selective examination of certain aspects of a
problem.
The goal of abstraction is to isolate those aspects that are
important for some.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 12
Brindavan College, Bangalore
3 models
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 13
Brindavan College, Bangalore
Class model
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 14
Brindavan College, Bangalore
State model
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 15
Brindavan College, Bangalore
Interaction Model
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 16
Brindavan College, Bangalore
Relationship among the Models
• Class model describes properties and behavior on which the
state and interaction model operate.
• State model shows decisions that depend on object value ,the
decisions causes changes in object value and subsequent
states.
• Interaction model provide overview of the operation of a
system.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 17
Brindavan College, Bangalore
Object and Class concepts
Objects
Define objects as a concept, abstraction or thing with identity that
has meaning for an application.
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.
Classes
An object class describes a group of objects with similar properties
(attributes), behavior (operations), relationships to other objects and
semantics.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 18
Brindavan College, Bangalore
Class diagram:
Person Company
Class diagrams are useful both for abstract modeling and designing
actual program.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 19
Brindavan College, Bangalore
Object diagram
• It shows individual objects and their relationship.
• A class diagram can have infinite set of object diagram.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 20
Brindavan College, Bangalore
Values and Attributes
• A Value is a piece of data.
• An attribute is a named property of a class that describes a value
held by each object of the class.
• Each attribute name is unique within a class.
• An attribute should be a pure data value, not an object.
Person JoeSmith:Person
name: string name: “JoeSmith”
age: integer age: 20
birthdate: date birthdate: 1 Jan 1993
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 21
Brindavan College, Bangalore
Links and Association Concepts
Link
• Links and associations are the means for establishing relationships
among objects.
• An association describes a group of links with common structure
and semantics.
Association
• Association is a group of links having common structure and
common behavior.
• Association depicts the relationship between objects of one or
more classes
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 22
Brindavan College, Bangalore
Degree of an Association
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 23
Brindavan College, Bangalore
Cardinality Ratios of Associations
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 24
Brindavan College, Bangalore
Multiplicity
• It specifies how many instances of one class may relate to a single
instance of an associated class.
• Multiplicity depends upon assumptions and how you define the
boundaries of a problem
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 25
Brindavan College, Bangalore
Generalization and Inheritance
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 26
Brindavan College, Bangalore
Use of generalization
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 27
Brindavan College, Bangalore
Generalization and Specialization
Generalization and specialization represent a hierarchy of
relationships between classes, where subclasses inherit from super-
classes.
Generalization
• The common characteristics of classes are combined to form a
class in a higher level of hierarchy.
• It represents an “is – a – kind – of” relationship.
Specialization
• Specialization is the reverse process of generalization.
• The distinguishing features of groups of objects are used to form
specialized classes from existing classes.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 28
Brindavan College, Bangalore
Continue…
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 29
Brindavan College, Bangalore
Class Diagram
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 30
Brindavan College, Bangalore
Activity
Draw a Class Diagram
1. Whatsapp Application
2. Atm machine
3. Facebook
4. Amazon online shopping app
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 31
Brindavan College, Bangalore
NAVIGATION OF CLASS MODELS
• Class models are useful for more than just data structure.
• Navigation of class model lets you express certain behavior.
• Navigation exercises a class model and uncovers hidden flaws
and omission, which you can then repair.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 32
Brindavan College, Bangalore
Object constraint language(OCL).
OCL can traverse the constructs in class models
1. Attributes
2. Operations
3. Simple associations
4. Qualified associations
5. Associations classes
6. Generalization
7. Filters
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 33
Brindavan College, Bangalore
Write an OCL expression for –
1. What transactions occurred for a credit card account within a time
interval?
Soln: aCreditCardAccount.Statement.Transaction ->
select(aStartDate<=TransactionDateand
TransactionDate<=anEndDate)
2. What volumes of transactions were handled by an institution in the
last
year?
Soln: anInstitution.CreditCardAccount.Statement.Transaction ->
select(aStartDate<=TransactionDateandTransactionDate<=anEndDate).a
mount-
>sum( )
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 35
Brindavan College, Bangalore
Continue…
3. What customers patronized a merchant in the last year by any kind
of
credit card?
Soln: aMerchant.Purchase -> select(aStartDate<=TransactionDate
andtransactionDate<=anEndDate).Statement.CreditCardAccount.Maili
ngAddress.Cu
stomer ->asset( )
4. How many credit card accounts does a customer currently have?
Soln: aCustomer.MailingAddress.CreditCardAccount -> size( )
5. What is the total maximum credit for a customer for all accounts?
Soln: acustomer.MailingAddress.CreditCardAccount.Maximumcredit
Manisha Kumari -
Assistant Professor
> sum( )
Object oriented modeling and design PG Dept. MCA 36
Brindavan College, Bangalore
Advanced Class Modeling
• Advanced object and class concepts
• Association ends
• N-array association
• Aggregation
• Abstract classes
• Multiple inheritance
• Metadata
• Reification
• Constraints
• Derived data
• Packages Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 37
Brindavan College, Bangalore
Advanced object and class concepts
Enumerations
A data type is a description of values, includes numbers, strings,
enumerations
Enumerations: A Data type that has a finite set of values.
We can declare an enumeration by listing the keyword enumeration
in guillemets (<< >>) above the enumeration name in the top
section of a box. The second section
lists the enumeration values.
Eg: Boolean type= { TRUE, FALSE}
Eg: figure.pentype _____ - - - - - -------
Two diml.filltype
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 38
Brindavan College, Bangalore
Continue…
Enumerations
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 39
Brindavan College, Bangalore
Multiplicity
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 40
Brindavan College, Bangalore
Scope
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 41
Brindavan College, Bangalore
Visibility
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 42
Brindavan College, Bangalore
Associations ends
• Association End is an end of association.
• A binary association has 2 ends; a ternary association has 3
ends.
• Association end name
• Multiplicity
• Ordering
• Bags and sequence
• Qualification
• Aggregation
• Changeability
• Navigability
• Visibility Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 43
Brindavan College, Bangalore
N-ary Association
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 46
Brindavan College, Bangalore
Abstract Classes
• An abstract class is a class that has no direct
instances but whose descendant classes have
direct instances.
• A concrete class is a class that can have direct
instances.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 47
Brindavan College, Bangalore
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 48
Brindavan College, Bangalore
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 49
Brindavan College, Bangalore
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 50
Brindavan College, Bangalore
Module 3
Draw Class Diagram for Super Market
Management System.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 51
Brindavan College, Bangalore
Exercise
1. What transactions occurred for a credit card
account within a time interval?
2. What volumes of transactions were handled by an
institution in the last year?
3. What customers patronized a merchant in the last
year by any kind of credit card?
4. How many credit card accounts does a customer
currently have?
5. What is the total maximum credit for a customer
for all accounts?