Introduction to Class Diagrams - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Introduction to Class Diagrams

Description:

You can refer to Select Enterprise v6 for further information: Help, Modelling, ... The special association of a car to its component parts is aggregation ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 19
Provided by: Staffordsh75
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Class Diagrams


1
Introduction to Class Diagrams
  • There is nothing particularly object-oriented
    about Use Cases - they take a process-centric
    view of the problem
  • We now need to turn that work on use cases into
    object-oriented work
  • Classes can then be coded into Java Classes

2
The OODI Methodology
  • Analysis, Design, Implementation

Object Interaction/ statediagrams
3
What is a Class?
  • A class is a thing or event of significance to
    the system
  • A class can have attribute (data item)
    definitions and operations (behaviour)
  • Individual Objects have the attribute values and
    exhibit the behaviour which was defined in the
    class to which they belong
  • This is fundamentally an object oriented premise

4
What is a Class Diagram?
  • The Class Diagram describes the static structure
    of the classes in a system and their associations
    (relationships)
  • Initially, the Class Diagram should show only
    classes and associations
  • Next, the attributes and operations can be added

rents


Video
Customer
?
5
Why use a Class Diagram?
  • Depicts meaningful concepts and terms for the
    problem
  • a sort of visual dictionary
  • improve comprehension of the problem
  • clarifies important information
  • can lead to revision of the Use Case Model
  • achieves a starting set of software classes
    which can be refined as we progress through the
    life cycle

6
Building a Class Diagram
  • 1. identify the Classes and then draw a
    preliminary diagram and then later.
  • 2. identify the preliminary associations and add
    them to the diagram
  • 3. identify the attributes and add them to the
    diagrams
  • 4. identify the operations and add them to the
    diagram

7
1. How to identify the Classes?
  • Various strategies exist! The objects are out
    there Identification is not always easy!
  • 1.1. Work through a common concept categories
    list
  • 1.2. Linguistic (Abbott) analysis of the
    problem vocabulary and the Use Case scripts you
    have created
  • 1.3. Create skeleton CRC cards during informal
    brainstorming meetings
  • 1.4. Find and apply existing models(patterns)
    from published sources

8
1.1 Common concept categories example
  • Concept category Class
  • physical object video
  • specifications, designs video description
  • transactions sales, payment
  • roles customer
  • organisations video store
  • rules and policies LoanPolicy

9
1.2 Abbott Analysis
  • Abbott, R., Communications of the ACM, Program
    Design by Informal English Descriptions 1983
  • make a list of the nouns or noun phrases in
    descriptions of the problem area, requirements
    document or the Use Case script
  • discuss these candidate classes and normally many
    will be discarded
  • rather simplistic but very useful

10
1.3 CRC Cards(Class, Responsibility,
Collaboration)
  • To enable a team to decide which are the
    candidate classes after nouns analysis.
  • Stages
  • 1. Write the name of each noun on a card.
  • 2. Discuss the need for the class and discard a
    class if necessary - identify each as a definite
    class/ definite rubbish/ a doubtful class
  • 3. Write a short description of the purpose of
    this class

11
2. Identify Associations
  • Method
  • 1. make a list of the verbs in descriptions of
    the problem area, requirements document or the
    Use Case script
  • 2. pair every class with every other class and
    decide if there is a meaningful relationship
  • 3. On the CRC card identify Collaborators - the
    other classes that this class send / receive
    messages to / from

12
Associations (contd)
  • Associations are shown as lines on the class
    diagram
  • Multiplicity can be shown at each end of an
    association by - any number 1 -
    only 1 2.. - 2 or more 3..14 -
    between 3 and 14 inclusive 3,5..7 - either 3
    or between 5 and 7 inclusive

13
3. Identify Attributes
  • Attributes in Class diagrams are just like
    attributes in entity relationship models
  • Attribute type and default values can be shown on
    the class diagram
  • Attributes are listed in the 2nd level of a class
    box i.e after class name

Class Name
Attributes
Operations
14
4. Identify Operations
  • Operations are functions that may be applied to
    or by objects in a class - use verbs
  • On the CRC card identify Responsibilities - what
    must this class do and what it knows
  • A method is the implementation of an operation
  • Operations are listed in the lower third of the
    class box. Each operation name may be followed
    by optional details such as argument list and
    result type

15
Further Reading
  • You can refer to Select Enterprise v6 for further
    information Help, Modelling,
    Class Modelling, Techniques, 1.
    Discovering Classes 2. Examining Use Cases
    for Classes 3. Examining Events for Classes

16
Class Diagrams - Special Associations
  • Generalisation - inheritance modelling
  • Specialisation - inheritance modelling
  • Aggregation
  • These will appear as we progress with the design
    - if there are obvious superclasses/subclasses
    then great - include them but otherwise wait
    until you modelled the dynamic behaviour
  • We will return to this subject to examine OO
    principles such as reuse

17
Generalisation and Specialisation
  • Inheritance is basically describes 'type-of'
    relationships
  • Inheritance in shown in an class diagram by a
    triangle see example
  • A discriminator is shown alongside the
    generalisation symbol - see Class Diagrams How
    To document
  • E.g. Clerk is type-of Employee

18
Aggregation
  • Aggregation is used to represent 'part-of'
    relationships between classes.
  • Aggregation is shown by the empty diamond in the
    class hierarchy at one end of a relationship line
  • Cars are made up of steering wheels, engines,
    transmissions etc. Each of these components may
    be an object(class) in its own right. The
    special association of a car to its component
    parts is aggregation
Write a Comment
User Comments (0)
About PowerShow.com