0% found this document useful (0 votes)
37 views

Cours 3 - Classes Structurées Et Collaborations

1) The document discusses object-oriented design principles like classes, associations, generalizations, and aggregations/compositions. 2) It provides examples of how to model relationships between classes using associations, generalizations, and structured classifiers. 3) The key concepts covered include single and multiple inheritance for generalizations, different types of associations and their multiplicities, and distinguishing between aggregation and composition relationships.

Uploaded by

mor ndiaye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Cours 3 - Classes Structurées Et Collaborations

1) The document discusses object-oriented design principles like classes, associations, generalizations, and aggregations/compositions. 2) It provides examples of how to model relationships between classes using associations, generalizations, and structured classifiers. 3) The key concepts covered include single and multiple inheritance for generalizations, different types of associations and their multiplicities, and distinguishing between aggregation and composition relationships.

Uploaded by

mor ndiaye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Classes Structurées et Collaborations

Conception Orientée Objets

Classes Structurées et 
Collaborations
Frédéric Mallet

http://deptinfo.unice.fr/~fmallet/
F. Mallet ‐ COO 1
Classes Structurées et Collaborations

Classes are grouped within Packages

Registration

CloseRegistrationForm CloseRegistrationController

RegisterForCoursesForm RegistrationController

F. Mallet ‐ COO 2
Classes Structurées et Collaborations

Associations
 The semantic relationship between two or more 
classifiers that specifies connections among their 
instances. 
A structural relationship specifying that objects of one 
thing are connected to objects of another thing.

Student Schedule Course

How to decide which associations? Which methods?

F. Mallet ‐ COO 3
Classes Structurées et Collaborations

Use interactions to find associations
1: submit schedule( ) 2: submit schedule( )
: RegisterForCoursesForm : RegistrationController

: Student
8: any conflicts?( )

3: save( )
4: submit( )

: Schedule 7: still open?( )


9: add student(Schedule)

6: has pre-requisites(CourseOffering)

: CourseOffering
: Student
5: is selected?( )
10: mark as enrolled in( )

: PrimaryScheduleOfferingInfo

F. Mallet ‐ COO 4
Classes Structurées et Collaborations

Structural Diagrams
Static view of a system
CloseRegistrationForm Schedule CloseRegistrationController
- semester
+ open() + is registration open?()
+ close registration() + commit() + close registration()
+ select alternate()
+ remove offering()
+ level() Professor
+ cancel() - name
Student + get cost() - employeeID : UniqueId
+ delete() - hireDate
+ submit() - status
+ get tuition()
+ save() - discipline
+ add schedule()
+ any conflicts?() - maxLoad
+ get schedule()
+ create with offerings()
+ delete schedule()
+ update with new selections() + submitFinalGrade()
+ has pre-requisites()
+ acceptCourseOffering()
+ setMaxLoad()
+ takeSabbatical()
+ teachClass()

F. Mallet ‐ COO 5
Classes Structurées et Collaborations

Generalization
A relationship among classes where one class shares 
the structure and/or behavior of one or more 
classes.
Defines a hierarchy of abstractions where a subclass 
inherits from one or more super classes.
 Single inheritance
 Multiple inheritance
Is an “is a kind of” relationship.

F. Mallet ‐ COO 6
Classes Structurées et Collaborations

Example: Single Inheritance
One class inherits from another.
Ancestor
Account
- balance
Superclass - name
(parent) - number

+ withdraw()
+ createStatement()

Generalization
Relationship

Subclasses
Savings Checking
(children)

Descendents
F. Mallet ‐ COO 7
Classes Structurées et Collaborations

Example: Multiple Inheritance
A class can inherit from several other classes.

FlyingThing Animal

Multiple Inheritance

Airplane Helicopter Bird Wolf Horse

Use multiple inheritance only when needed and


always with caution!

F. Mallet ‐ COO 8
Classes Structurées et Collaborations

Multiplicity
 Multiplicity is the number of instances one class relates to ONE 
instance of another class.
 For each association, there are two multiplicity decisions to make, 
one for each end of the association.
 For each instance of Professor, many Course Offerings may be taught.
 For each instance of Course Offering, there may be either one or zero 
Professor as the instructor.

instructor
Professor CourseOffering
0..1 0..*

F. Mallet ‐ COO 9
Classes Structurées et Collaborations

Complex Associations
Ternary association

Association Classes

F. Mallet ‐ COO 10
Classes Structurées et Collaborations

Complex Associations
Qualified Associations

F. Mallet ‐ COO 11
Classes Structurées et Collaborations

Aggregation
 A special form of association that models a whole‐part 
relationship between the aggregate (the whole) and its 
parts.
 An aggregation is an “is a part‐of” relationship.
 Multiplicity is represented like other associations.

Whole 1 Part

0..1

F. Mallet ‐ COO 12
Classes Structurées et Collaborations

Composition
 A special form of aggregation where the composite (the 
whole) is responsible for the existence of the parts
 An aggregation is an “owns” relationship
 Composition is more restricting than aggregation
 Parts (instances) are not shared
 E.g., A wheel is not shared between two cars

Car Wheel

F. Mallet ‐ COO 13
Classes Structurées et Collaborations

Composite Structure
Richer and more precise way to express composition
 Can also express aggregation (dashed lines)
 Warning: Parts are Properties, not instances

Car

4 Wheel a : Axle
Engine
2

Parts
F. Mallet ‐ COO 14
Classes Structurées et Collaborations

Structured classifiers
Show roles of parts
 Parts ARE NOT instances

Car

frontL : Wheel rearLeft : role


Wheel

: Engine

frontRight : rearRight :
Wheel Wheel

F. Mallet ‐ COO 15
Classes Structurées et Collaborations

Instance of a structured classifiers
Show roles of parts
 Instance parts have
• An instance name, a role and a type (optional)

mycar : Car

energy1 / energy3 / Instance name


frontL : Wheel rearLeft :
Wheel role

: Engine type

energy2 / energy4 /
frontRight : rearRight :
Wheel Wheel
F. Mallet ‐ COO 16
Classes Structurées et Collaborations

Structured Classifiers
Metamodel

F. Mallet ‐ COO 17
Classes Structurées et Collaborations

Connectors and Ports
Provided & Required Interfaces

F. Mallet ‐ COO 18
Classes Structurées et Collaborations

COLLABORATIONS

F. Mallet ‐ COO 19
Classes Structurées et Collaborations

Collaborations
Semantics
 How a system of communicating elements collectively 
accomplish a specific task or set of tasks  (pattern)
Metamodel

F. Mallet ‐ COO 20
Classes Structurées et Collaborations

Example
Collaboration
« collaboration »
Sale

Buyer Seller

CollaborationUse

F. Mallet ‐ COO 21

You might also like