CPSC333 SENG 311: Foundations Principles of SE - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

CPSC333 SENG 311: Foundations Principles of SE

Description:

they are not killed when the Flames disappear. Polygon. color. texture. Point. Graphics ... Draw a class diagram to model the following information: ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 26
Provided by: rosejoshua
Category:

less

Transcript and Presenter's Notes

Title: CPSC333 SENG 311: Foundations Principles of SE


1
CPSC333 / SENG 311 Foundations / Principles of SE
  • Class Diagrams Part Two

2
Agenda
  • Class diagrams Tips and Tricks
  • Classes and Objects
  • Aggregation
  • Example

3
When to use class diagrams
  • Class diagrams are the backbone of OO development
    approaches
  • Dont use all the notations
  • start with simple features
  • use advanced features only when necessary
  • Take the perspective into account
  • not too many details in analysis
  • specification models during design
  • use implementation models only to illustrate
    particular implementation techniques

4
When to use class diagrams (cont.)
  • Concentrate on key areas
  • better few up-to-date diagrams than many obsolete
    models
  • Focus on conceptual and specification perspectives

5
How to define classes ? (Rules of Thumb)
  • Look for nouns in the Use Cases
  • Define a class for every noun ( add others)
  • Document the set of rules that determine the set
    of objects belonging to the class
  • Add associations to model the relations
  • Think about the subset relationship to build
    generalizations ...
  • Use object characteristics for attributes
  • Use objects activities for operations

6
Creating a class diagram
  • Start simple
  • major classes obvious associations
  • Then add
  • Attributes
  • Multiplicity
  • Operations
  • Responsibilities

7
Avoid Heavy classes
  • Controller does everything
  • Other classes Data encapsulation only

A
D
HeavyControler
doIt( )
?DO NOT DO IT!!!! ?
B
C
8
Agenda
  • Class diagrams Tips and Tricks
  • Classes and Objects
  • Aggregation
  • Example

9
Classes and Objects
  • As mentioned, a class defines the structure of a
    group of objects
  • It defines
  • name
  • attributes
  • operations

10
Classes and Objects
  • Objects show
  • Object name (underlined)
  • Class name (optional)
  • Attribute value (optional)




11
Example of Classes and Objects
Order
Salesperson
Line
Class diagram
CustInfo
line1 Line
order121Order
curtisClyde
line2
ace furniture
Named instance
line3
line4
Object diagram
Order
line1
harmon assoc
anonymous instance
line2
orphan instance
12
Agenda
  • Class diagrams Tips and Tricks
  • Classes and Objects
  • Aggregation
  • Example

13
Aggregation
  • Special form of association
  • Components are parts of aggregated object
  • Car has an engine and wheels as its part
  • Aggregation is transitive
  • Anti-symmetric Object may not be directly or
    indirectly part of itself
  • Typical example
  • parts explosion
  • organizational structure of a company

14
Notation for aggregation
or
  • conceptually distinguishes the whole from the
    part
  • No info concerning navigability or life-time

15
Example Aggregation
Company
Unit

Department


Group
works for

Employee
16
Aggregation and composition
  • Composition
  • Parts belong only to one whole
  • Parts live and die with the whole
  • cascading delete
  • Note Also needed for 1..1 associations
  • The players can be aggregated for the
    FlamesBUTthey are not killed when the Flames
    disappear

17
How to recognize aggregation?
  • Question Association or aggregation?
  • Description part of correct?
  • Operation on whole affects parts, too?

18
Recursion
  • Directed path of aggregation associations from a
    class to itself
  • Variable aggregation finite number of levels,
    number of parts variable (example company)

19
Example recursive aggregation
Object diagram
a Container
Class diagram

Item
c Container
b Icon
Icon
Container
d Icon
e Icon
20
Example Recursive aggregation

Class
21
Rules for using aggregation
  • Distinction between association and aggregation
    often rather matter of taste than difference in
    semantics
  • Aggregation IS association
  • Aggregate is inherently sum of its parts
  • In Object Diagrams Chains of aggregate links
    must not form cycles
  • Composition is appropriate when each part is
    owned by one object, part does not have an
    independent life from its owner

22
Agenda
  • Class diagrams Tips and Tricks
  • Classes and Objects
  • Aggregation
  • Example

23
Class Diagram - Example
  • Draw a class diagram to model the following
    information
  • A zoo consists of a set of cages.
  • Every cage is the home of at least 2 animals.
  • Cages are located besides each other.
  • Every cage has at most one left neighbor and at
    most one right neighbor.
  • Animals can be reptiles, insects, and mammals.
  • Mammals are elephants, monkeys, and tigers.
  • Monkeys eat bananas.
  • Tigers prefer meat.

24
Class Diagram - Example
  • Draw a class diagram to model the following
    information
  • A University is made up of several departments.
    It also has academic and non-academic staff who
    work for the University. The academic staff,
    called Professors, teach students. Students take
    courses. Courses are held in rooms. Each room
    can be assigned to as many courses as possible,
    subject to scheduling constraints. A student can
    also work for the university. Every staff
    receives payroll once a month. Payroll is
    subject to government taxes.

25
Were Available!
  • Questions?
  • if you have any questions about contents of this
    lecture or other course-related issues, please
    come by during our office hours, or send us
    email
  • Dr. Joshua MTW, 12-1pm, ICT 548
  • joshuar_at_cpsc.ucalgary.ca
  • Dr. Walker WF, 1-2pm, ICT 546
  • rwalker_at_cpsc.ucalgary.ca
Write a Comment
User Comments (0)
About PowerShow.com