Download - Introduction to advance class modelling
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modellingIntroduction to
advance class modelling
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Advanced Object & Class Concept
• Enumerations• Multiplicity• Scope• Visibility
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Enumeration• An enumeration is a data type that has finite set of
values:• For ex.
• Enumeration often occur and are important to users.– i.e. it display only the possible values or users are restricted to
access only allowed values or data.• Do not use generalization to capture the values of an
enumerated attributes
Calendarweek: Week
<<enumeration>>week
SundayMondayTuesday…….Saturday
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• An enumeration list of values• Generalization Structuring the description of objects.
– Ex. We are not introducing generalization for “Card” Class because most games do not differentiate the behavior of “Suit”.
Card
suit:suitrank: rank
<<enumeration>>Suit
SpadesClubsHeartsdiamonds
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
UML notation
• Top section: Write keyword enumeration in between “<<>>” above enumeration name.• Second section : List the enumeration values.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Multiplicity
• Multiplicity is a constraint on the cardinality of a set.• Multiplicity for an attribute specifies the number of possible values for each representation of attributes.• Common specifications are
– Mandatory single value [1]– An optional single value [0..1]– Many[*]
• It specify whether an attribute is mandatory or optional• It indicates if an attribute is single valued or can be a collection.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• If not specified, it is assumed to be a mandatory single value[1]
Person
name: string[1]address:string[1..*]birthdate:date[1]
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Scope• It indicates if a feature applies to an object or
a class.• You should avoid attributes with class scope
because they can lead inferior model.• It is better to model group explicitly and assign
attributes to them.
Personname
PhoneMailBox
maxMessageCountphoneNumberpassword
PhoneMessage
maximumDurationmaxDaysRetaineddateRecordedtimeRecordedpriority
1 * *
*
0..1
source
owner
1
{ordered}
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Upper model is inferior because the maximum duration, maximum day retained and maximum message count have a single value for the entire phone mail system.
• It is acceptable to use an attribute with class scope to hold the extent of a class ( Set of objects for a class)
Personname
PhoneMailBox
phoneNumberpassword
PhoneMessagedateRecordedtimeRecordedpriority
1 **
*
0..1
source
owner
1
{ordered}
MailCategory
maxMessageCount maximumDurationmaxDaysRetained
1
*
owner
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• It is also acceptable to define operations of class scope.• It is convenient to define class scoped operations to provide summary data.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Visibility
• Visibility refers to the ability of a method to reference a feature from another class and has the possible values of – Public, – Protected– Private– Package
• Public features: Any method freely access• Protected features: only methods of the containing class and its descendant via inheritance can access• Private features: only methods of the containing class can access.• Package features: Methods of classes defined in the same package as the target class can access.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• UML denotes visibility with a prefix.– Character “+” precedes public– Character “-” precedes private– Character “#” precedes protected– Character “~” precedes package
• Several issues when choosing visibility– Comprehension
• You must understand all public features to understand the capabilities of a class. • Others are merely an implementation convenience.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Extensibility– Many classes can depend on public methods, so it can be highly disruptive to change their signature.– Fewer classes depend on private, protected, and package methods, there is more latitude to change them.
• Context– Private, protected and package methods may rely on preconditions or state information created by other methods in the class. – A private method may calculate incorrect results or cause the object to fail.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Association ends
• A binary association has two ends, a ternary association has three ends and so forth.Few properties:• Association end name:
– An association end may have meaningful name.– Names clarifies multiple references to a class and facilitate navigation
• Multiplicity:– Can specify multiplicity for each association end.
• Ordering:– Objects for a “many” association end are usually just a set.
• Bags & Sequences:– Objects for a “many” association end also be a bag or sequence.
• Qualification:– One or more qualifier attributes can disambiguate the objects for “many” association end
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Additional properties
• Aggregation:– It may be an aggregate or constituent (element) part.– Only binary association can be a aggregation:
• One association end must be an aggregate• Other must be a constituent
• Changeability:– It specifies the update status of an association end.
• Navigability– UML shows navigability with an arrowhead on the association end attached to the target class.– Arrowheads may be attached to zero, one or both ends of an association.
• Visibility– Similar to attributes and operations, association ends may be public, protected, private or package.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
N-ary AssociationsProject
Person
Language*
*
*
programmer
• N-ary associations mean associations among three or more classes.– Ex. Programmers use computer languages on projects.
• UML notation:– It is diamond with lines connecting to related classes.– If the association has a name, written in italics next to the
diamond.Note:• Avoid n-ary associations – most of them can be decomposed into
binary associations, with possible qualifiers and attributes.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• N-ary association can have a name for each end just like binary associations.
• You can not traverse n-ary associations from one end to another as with binary associations.
Semester
ListedCourse
Professor
*
*
*
DeliveredCourse
roomNumberTextbook
* *
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Ex. A professor teaches a listed course during a semester. The resulting delivered course has a room number and any number of textbooks.
• Programming language can not express n-ary associations.• So you need to promote (support) n-ary associations to
classes.• When you promote n-ary associations to a class, might change
the meaning of a model.• An n-ary associations enforces that there is most one link for
each combinations.– Ex. For each combinations of professor, semester and
ListedCourse there is one DeliveredCourse • So if you were implementing below fig. special application
code would have to enforce the uniqueness of Professor + Semester + ListedCourse.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Semester
ListedCourse
Professor
DeliveredCourse
roomNumber Textbook
1
1
*
* * *
*
1
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• UML has two forms of part-whole relationships:– Aggregation - A general form – Composition – More restrictive.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Aggregation
• Definition:– An aggregation as relating an assembly class to one constituent part class.– An assembly with many kinds of constituent parts corresponds to many aggregations.– For ex.
• College consists of students, professor, courses etc.• Here college is assembly and the others are constituents. • Therefore, college to student is one aggregation, college to professor is another aggregation.
– We define each individual pairing as an aggregation.– So that we can specify the multiplicity of each constituent part within the assembly.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Aggregation is an special form of binary associations.• Most important property of aggregation:
– Transitivity• If A is part of B and B is part of C, then A is part of C.
– Antisymmetric• If A is part of B, then B is not part of A.
• Aggregate operations imply transitive closure and operate on both direct and indirect parts.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Aggregation v/s Association
• Aggregation is not an independent concept, it is a special form of association.• If two objects are tightly bound by a part-whole relationship, it is an aggregation.• If two objects are usually considered as independent and have linked, it is association. To find whether there is a aggregation or not, some tests includes:
– Use the phrase part of– Some operations on the Whole apply to its parts– Some attributes values circulate from whole to all or some parts.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
UML notation:• Like association, except a small diamond indicates the assembly
end. • Decision to use aggregation is
– Matter of Judgment– Arbitrary
College
ProfessorStudent
Courses
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Aggregation v/s Composition• Composition is a form of aggregation with two
additional constraints.– A constituent part can belong to at most one
assembly.– Once its assigned, it has coincident lifetime with
the assembly.• Composition implies ownership of the parts by
the whole. • Composition is convenient for programming
– Ex. Deletion of assembly object triggers deletion of all constituent objects.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
UML notation:• Composition is a small solid diamond next to assembly
class.
EX. A company consists of divisions, which in turn consists of departments.
• A Company is indirectly a composition of departments.
Company
Person
Division Department1
*
* *1
1WorksFor
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modellingPropagation of operations
• Propagation is the automatic application of an operation to a network of objects. When the operation is applied to some starting object.
• Ex. A persons owns multiple documents.• Copy operations propagate from document to paragraph to
characters. • Copying a paragraph copies all the characters in it.• Operation does not propagate in the reverse direction: A
paragraph can be copied without copying the whole document.
Personcopy()
Documentcopy()
Paragraphcopy()
Character
1 *
Owns
1 *
Copy4
1 *
Copy4
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
UML notation:• Small arrow indicating the direction and operation name next to the affected association.Note: this notation is not part of the UML and is a special notation.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
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 is instantiable; it can have direct instances.• Only concrete classes may be leaf classes in an inheritance tree.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Baker and candelstickMaker are concrete classes because they have direct instances.
Worker
Baker CandlestickMaker
{ note: listing of workers is incomplete}
Concrete Class: it can have direct instances.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
ComputePay()
yearToDateEarnings
Employee
ComputePay()weeklyRate
FullTimeEmployee
ComputePay()hourlyRate
PartTimeEmployee
Abstract Class and Abstract operation: it has not direct instances.
FullTimeEmployee and PartTimeEmployee are concrete classes because they can be directly instantiated.
UML Notation:Abstract class name listed in italic font or may place
keyword {abstract} below or after the name.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• An abstract class can define signature for an operation without supplying corresponding method.
• An abstract operation defines the signature of an operation for which each concrete subclass must provide its own implementation.
• A concrete class may not contain abstract operations.UML Notation:• An abstract operation is designated by italics or the
keyword {abstract}. Note:• Abstract nature of a class is always provisional,
depending on the point of view or application.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Multiple Inheritance
• It permits a class to have more than one superclass and to inherit features from all parents. • More complicated form of generalization than single inheritance. • Advantage is greater power in specifying classes and an increased opportunity for reuse.• Disadvantage is a loss of conceptual and implementation simplicity.• Multiple inheritance mean either the conceptual relationship between classes or the languages mechanism that implements that relationship.• Distinguish between
– Generalization : conceptual relationship– Inheritance : Language mechanism.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Kinds of multiple Inheritance• Common form of multiple inheritance is from
sets of disjoint classes.• Each subclasses inherits from one class in each
set.
FullTimeIndividualContributor
FullTimeEmp PartTimeEmp Manager IndividualContributor
Employee
employementStatus managerialStatus
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Here, FullTimeEmp and PartTimeEmp are disjoint; and Manager and IndividualContributor are also disjoint classes.
• We can also define additional combinations classes here like FullTimeManager, PartTimeContributor, PartTimeManager and FullTimeIndividualContributor.
• Each generalization should cover a single aspect (A generalization set name).
• Therefore, here class Employee has two aspect – Employment Status– Managerial Status
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• So, FullTimeIndividualContributor inherits Employee features along two paths via employmentStatus and managerialStatus.• Conflicts among parallel definitions create ambiguities. • You should avoid such conflicts in models or explicitly resolve them.
– For Ex. FullTimeEmp and IndividualContributor both have attribute called name.– FullTimeEmp.name could refer as person’s full name and IndividualContributor.name might refer as person’s title.
• Solution is restating the attributes of classes.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Multiple inheritance can also occur with overlapping classes.
landVehicle watervehicle
Amphibiousvehicle boatCar
Vehicle
{overlapping, incomplete}
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• AmphibiousVehicle is both Land and water vehicle. So there is a overlapping.• UML uses constraint to indicate an overlapping generalizations set;• Notation is a dotted line cutting across affected generalization with keyword in braces.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modellingMultiple Classification
Definition:– One instance happens to participant in two overlapping
classes.
Person
Faculty
UniversityMember
Student Staff
Instructor
1 *
{Overlapping: }
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• UML permits multiple classification but most OO languages handle it poorly. • Fig. show that Person as an object composed of multiple UniversityMember object. • This workaround replaces inheritance with delegation.• This is not totally satisfactory, there is a loss of identity separates roles.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Workaround
• Dealing with multiple inheritance is implementation issue but early restructuring of a model is often the easiest way to work around its absence.• Two approaches make use of delegation, which is an implementation mechanism by which object forwards an operation to another object for execution.• Restructuring technique
– Delegation using composition of parts– Inherit the most important class and delegate the rest.– Nested generalization
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Delegation using composition of parts– You can recast superclass with multiple independent generalization as a composition in which each constituent part replaces a generalization. – Single object having a unique ID by a group of related objects that compose an extended object.– Inheritance of operations across the composition is not automatic.– Composite must capture operations and delegate to appropriate part.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modellingEmployee
EmployeeEmployment EmployeeManagement
FullTimeEmployee PartTimeEmployee IndividualContributorManager
1
11
1
employmentStatus managerialStatus
You need not create various combination as explicit classes.
All combinations of subclasses from the different generalizations are possible.
Workaround for multiple inheritance - delegation
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Inherit the most important class and delegate the rest.– Maintain identity and inheritance across the most important
generalization.– Reduce the remaining generalization to composition and delegate
their operations.
Employee EmployeeManagement
PartTimeEmployee IndividualContributorManager
1 1
employmentStatus managerialStatus
FullTimeEmployee
Workaround for multiple inheritance – inheritance and delegation
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Nested Generalization:– Factor on one generalization first, then the other.– This approaches multiplies out all possible combinations.– This preserves inheritance but duplicates declarations and
code and violates the spirit of OO programming.
Employee
FullTimeEmployee PartTimeEmployee
employmentStatus
FullTimeManager
PartTimeManager
FullTimeIndividualContributor
PartTimeIndividualContributor
fullTimeEmpStatus partTimeEmpStatus
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• There are several issue when selecting the best workaround.– Superclass of equal importance– Dominant superclass– Few subclass– Sequencing generalization sets– Large quantities of code– Identity
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Superclass of equal importance:– If a subclass has several superclasses it may be best to use
delegation and preserves symmetry in the model.• Dominant superclass:
– If one superclass clearly dominate and others are less important, preserve inheritance through this path.
• Few subclasses:– If the number of combinations is small, consider nested
generalization otherwise avoid.• Sequencing generalization sets.
– In a case of generalization, factor on most important criterion first, then second most and so forth.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Large quantities of code:– Try to avoid nested generalization, in a case of duplicate large quantities of code.
• Identity:– Consider the importance of maintaining strict identity. Only nested generalization preserves this.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modellingMetadata
Definition• Metadata is data that describes other data.
– For ex. A class definition is metadata.• Models are inherently metadata, they describe the things
being modeled.
modelNameyearbasePrice
CarModelmodelNameyearbasePrice
PhysicalCar
Company Person
*
manufacturer1
*1 Describes
owner 1
*
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• A car model describes many physical cars and holds common data.• A car model is metadata relative to a physical car, which is data.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Constraints
Definition• A constraint is Boolean condition involving model elements, such as objects, classes, attributes, links, associations and generalizations sets. • A constraint restricts the values that elements can assume.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modellingConstraints on objects
salary
Employee
boss 0..1
*lengthwidth
Window
priority
Job
Ex-1. No employee’s salary can exceed the salary of the employee’s boss. ( a constraints between two things)
Ex-2. No window can have an aspect ratio of less than 0.8 or greater than 1.5 ( a constraint between attributes).
Ex-3. Priority of a job may not increase (a constraint on the same object)
Employee.salary < boss.salary 0.8< length/width<1.5 Priority never increase
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Constraints on Generalization sets
• Class models capture many constraints through their structure.– For ex. The semantics of generalization imply certain structural
constraints.• With single inheritance the subclasses are mutually exclusive• UML had few keywords for generalization sets.
– Disjoint• The subclasses are mutually exclusive. Each object belongs exactly one of
subclasses.– Overlapping
• The subclasses can share some objects. An object may belongs to more than one subclass.
– Complete:• The generalization lists all the possible subclasses.
– Incomplete:• The generalization may be missing some subclasses.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Constraints on Links• Multiplicity is a constraint on cardinality set.• Multiplicity for an associations restricted the number of
objects related to a given object.• Qualification also constraints an association.• A qualifier attribute does not merely describe the
association but also significant in resolving the “many” objects.
• An association class implies a constraint.• An association class has constraint that an ordinary class
does not; it derives identity from instances of the related classes.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• There is no particular order on the objects of a “many” end for ordinary association.• But, constraint {ordered} indicates that elements of a “many” associations end have explicit order.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Use of constraints Declaration lets you express a constraint’s intent,
without supposing an implementation. That mean, convert constraints to procedural
form before implementation. Practically, you can not enforces every constraint
with model’s structure, but you should try to enforce the important ones.
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
UML notation• Two alternative notations of constraints:
– Delimit a constraint with braces or – place it in a “dog-eared” comment box.
• You should try to position constraint near affected elements.
• A dashed arrow can connect a constrained element to the element on which it depends.
{Constraint2: }priority
Job
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• The subject is not primarily about OO-language or coding.• This subject emphasize on initial stages of process development
i.e. Requirement Gathering Planning etc.
• Object-oriented analysis and design (OOAD) is a software engineering approach that models a system as a group of interacting objects.
OOAD Concept
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
OOAD is divided into two parts as follows:• OOA (Object Oriented Analysis):
– Definition :Object Oriented Analysis (OOA) is concerned with developing requirements and specifications • OOD (Object Oriented Design)
– Definition: Object Oriented Design (OOD) is concerned with developing object-oriented models of a software/system to implement the requirements identified during OOA
OOAD Concept
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• What is an object?1) any concept that represent a single thing2) a representation of a specific entity in the real world3) may be tangible (physical entity) or intangibleExamples: In the case of LMS, software or system itself is intangible object and student and Library clerk act as tangible objects.
What is an object?
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Organize software as a collection of discrete objects that incorporate both data structure and behavior.– Data structure data pattern or data style or
formation of data– Behavior things that the object can do that
are relevant to model• OO approach has 4 characteristics:
– Identity– Classification– Inheritance– Polymorphism
What is Object-Orientation?
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Identity • Classification
• Polymorphism
• Inheritance
Characteristics of Objects
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Definition : Discrete (i.e. unique) & distinguishable entities called objects.
Ex. A person is an object.His name is Identify Ex. Ram
Note:• Objects are uniquely identifiable by name.• Each objects has its own inherent identity.• In other words, two objects are distinct even if an their attribute values (i.e. name and size) are identical.Ex. Twins are two distinct person by identity
Characteristics of Objects - Identity
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Definition:– Objects with the same data structure
(attributes) & behavior ( operation) are grouped into a class.
• In OO systems, class is a set of objects that share common structure and common behavior
• Classes are important mechanisms for classifying objects.
• Each class describes a possibly infinite set of individual objects.
Characteristics of Objects - Classification
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Each objects is said to be instance of its class.
• Objects has its own value for each attributes but shares the attributes names & operations.
Example : Class Name : Circle Attributes : radius, center Operation : setCenter(), setRadius()
Characteristics of Objects - Classification
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Definition: Sharing of attributes & operations (features) among classes based on hierarchical relationship.– A superclass has general information that subclass
refine and elaborate.– Each subclass incorporates all the features of its
superclass and adds its own features.– In other words, defining new classes from the
existing one.
Characteristics of Objects - Inheritance
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Note: subclasses need not repeat the features of the superclass.Advantage: common features of several classes into a superclass can reduce repetition within design and programs.
Characteristics of Objects - Inheritance
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
class Person { String name; String age; void birthday () { age = age + 1; }}
class Employee extends Person { double salary; void pay () { ...}}
Every Employee has a name, age, and birthday method as well as a salary and a pay method.
Person
Employee
Inheritance is implied by is-a or kind-of relationship.
Characteristics of Objects – Example of Inheritance
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Definition– Same operation may behave differently for
different classes.– In simple words, “ One name multiple form”– Here operation mean – it’s a procedure or
transformation that an object perform or is subject to.
– For example , Class name is POLYGON– Attributes - vertices, border color, fill color.– Operations – Draw, erase, fill
– An implementation of an operation by a specific class is called Method
Characteristics of Objects – Polymorphism
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• OO Development refers to the software life cycle.i.e. Planning, Analysis, Design & Implementation
Why OO Development?• In essence of OO development is the
identification & organization of application concepts, rather than in a programming language.
70
What is OO Development?
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Earlier, OO community focused on implementation part rather than analysis and design.
• It focuses excessively on implementation mechanisms rather than the underlying thought process that support.
• An OO development approach encourage software developers to work & thinks in terms of the application throughout software life cycle.
71
OO Dev – Modeling Concept, Not implementation
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• OO development is a conceptual process independent of a programming language until the final stage.
• OO development is fundamentally a way of thinking & not a programming technique.
• It can serve as a medium for specification, analysis, documentation & interfacing as well as for programming
72
OO Dev – Modeling Concept, Not implementation
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• OO Development & Graphical notation represents OO concept.
• OO process consists of building a model of an application & then adding details to it during design.
• Same notation is used from – Analysis Design Implementation.
• So information is not lost or translated into the next stage [Reusability].
73
OO Dev – Modeling Concept, Not implementation
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• System Conception• Analysis• System Design • Class Design • Implementation
74
OO Development Stages
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• System Conception means origin of the system.
• S/W development begins with - business analyst or users conceiving an
application & formulating tentative requirement.
75
System Conception
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• System Conception• Analysis• System Design • Class Design • Implementation
76
OO Development Stages
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Task of Analyst- Must work with the requester (client) to
understand the problem, because problem statement are rarely complete or correct.
- To design the Analysis model which demonstrates what the desired system must do, not how it will be done.
- Analyst is not concerned about implementation decision.
77
Analysis
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
78
Analysis model
Domain model Application model
Description of real-world
objects reflected Within the system
Description of the parts of application system itself that are
visible to the user.
Ex. Bank account is domain model. Application model includes Saving accounts, current account, demat account etc.
Analysis
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
System ConceptionAnalysisSystem Design Class Design Implementation
79
OO Development Stages
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Task of system designer - must decide what performance characteristics to optimize.- choose strategy to attack the problem.- making tentative resource allocation.
• Ex. Designer might decide to change the window screen for fast & smooth working, even when windows are moved or erased.
System Design
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
System ConceptionAnalysisSystem Design Class Design Implementation
81
OO Development Stages
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Task of class designer- add details to analysis model- They determine data structures & algorithm for each of the operation of window class.- They elaborate both domain & application
objects using same OO concept & notation.
Class Design
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
System ConceptionAnalysisSystem Design Class Design Implementation
83
OO Development Stages
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Task of Implementers :-• Translates the classes & relationships developed during class design into particular programming language, database or hardware• During implementation, follow good software engineering practice so that traceability to the design is apparent (i.e. clear). Implementation
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• OO concepts apply throughout the System Development Life Cycle (SDLC)– i.e. Analysis design implementation
• Use same classes from stage to stage without a change of notation.
• Some classes are not part of analysis but are introduced during design or implementation.
Ex. Data structure such trees, hash table & linked list are not visible to users at the time of analysis.– but designers introduce them to support particular algorithms.
Summary of OO Development
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Models
Class Model
State model
Interaction model
Objects in the system and their relationship
Life history of objects in the system
Interaction among objects
Three Software Models
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Class model
•Describe the static structure of the objects in a system & their relationship •It define the context for software development.•Class model contains class diagram to express it.•A class diagram is graph phase.•Nodes are classes.•Arcs are relationship among classes.
Book Store
Relationship
classes
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
State Model
• Describe aspect of an object that change over time.• State model specifies & implement control with state
diagram• A state diagram is a graph whose
• Nodes are state• Arcs are transitions between state caused by events
State 1 State 2
State Diagram
Event
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Interaction model
•How the objects in a system co-operate to achieve broader results.•Interaction model start with•Use case that are elaborate into with sequence and activity diagram.
Use CasesActivity Diagram
Sequence DiagramElaborate
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Use cases:Focus on functioning of systemSimple mean, what a system does for users
Sequence diagramShows the object that interact Time sequence of their interactions
Activity diagramElaborate important processing steps.Activity diagrams can be used to describe the business and operational step-by-
step workflows of components in a system
Interaction Model
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
91
• Grady Booch• James Rumbaugh • Ivar Jacobson Are the man behind Invention of OO Modeling Technique.• Object Modeling Technique (OMT) concept evolved in 1991.
OO Modeling History
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
92
• In 1994 James Rumbaugh joined Rational (now the part of IBM) in 1994 & began working with Grady Booch on UML Notations.• In 1995, Ivar Jacobson also joined Rational & added his concept to the unification work.
OO modeling History
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
93
• In 1996 the Object Management Group issued a request for proposals for standard OO modeling notation.• Later Rational led the final proposal team, with Booch, Rumbaugh & Jacobson deeply involved.
OO modeling History
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
94
OO modeling History
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
OO themes are not unique to OO systems, they are particularly well supported.AbstractionEncapsulationCombining data and behaviorSharingEmphasis on the essence of an objectSynergy
OO THEME
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Abstraction:Focus on essential aspects of an application while ignoring details.
i.e. focusing on what an object is and does, before deciding how to implement it.Use of Abstraction:
Freedom to make decisions as long as possible by avoiding premature commitment to details.
Ability to abstract is probably the most important skill required for OO development.
OO THEME
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Encapsulations ( Information Hiding):
– It is separates the external ( accessible to objects) aspects of an objects from the internal ( hidden from other objects) implementation details.
– It prevents portions of a program from becoming so interdependent that a small change has massive ripple effects.
– For ex. You may want to change the objects to • Improve performance, Fix a bug, Consolidate
code, Support porting
97
OO THEME
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• Encapsulation is not unique to OO language but ability to combine data structure & behavior in a single entity makes encapsulation cleaner & powerful.
98
OO THEME
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Combining data & Behavior• In non-OO code, to display the content of a window
must distinguish the type of each figure, such as circle, polygon etc & call the appropriate procedure to display it.
• In OO code, program invoke the “Draw” operations on each figure and each object implicitly decide which procedure to use, based on its class.
• So caller of an operation need not consider how many implementation exist.
99
OO THEME
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
• So, maintenance is easier, because the calling code need not be modified when a new class is added.
• In an OO system, the data structure hierarchy matches the operation inheritance hierarchy.
100
Data structure Hierarchy
Procedure Hierarchy
Class Hierarchy
Is replaced by
OO THEME
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Sharing• OO technique promote sharing at different levels.• Sharing via inheritance is one of the main advantage of
OO language.• OO development not only lets you share information
within an application, but also offers the aspects of reusing designs & code on future projects.
• OO provides the tools to build libraries ( or collection) of reusable component.
101
OO THEME
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Emphasis on the essence of an object:– In OO technology, focus is on what an objects is
rather than how it is used.– Use of an object depend on the details of
application and often change during development.
– OO development greater emphasis on data structure & lesser emphasis on procedure structure.
102
OO THEME
Prepared By Jay Dave© RKU 2014
Object-Oriented Analysis and DesignAdvance class modelling
Synergy : • OO concepts can be used in isolation but
together they complement each other synergistically.
103
OO THEME