Introduction to Class Diagrams - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Introduction to Class Diagrams

Description:

How many videos can a member borrow at the same time? ... Attributes are listed in the 2nd level of a class box i.e after class name. Class Name. Attributes ... – PowerPoint PPT presentation

Number of Views:17
Avg rating:3.0/5.0
Slides: 21
Provided by: Staffordsh75
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Class Diagrams


1
Introduction to Class Diagrams
2
Example Class Diagram
3
What does that Class Diagram tell us?
4
Questions on the previous Class Diagram
  • How many loans can a member make?
  • How many videos can a member borrow at the same
    time?
  • If a member rents out a video, which operation
    handles it?
  • What do you suppose this operation may do (ie.
    its code)?
  • Which class should have the ListOutstandingLoans
    operation? Why?
  • Which class should have the ListLapsedMembers
    operation? Why?

5
When to do Class Diagrams
  • As previously mentioned there is nothing
    particularly object-oriented about Use Cases -
    they take a process-centric view of the problem
  • We now need to turn that early work on use cases
    into object-oriented work as part of our life
    cycle
  • Classes can be coded into Java Classes in the
    final step of the life cycle

6
The OO Life Cycle
  • Analysis, Design, Implementation

Object Interaction/ statediagrams
7
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

8
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
?
9
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

10
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

11
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

12
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

13
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

14
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

15
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

16
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

17
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
18
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

19
Summary QuestionsYou have had the answer to
these during the lecture
  • Why do we need to create a class diagram?
  • Is it possible to alter the Use Cases after doing
    the class diagram?
  • Is it OK to have multiplicity of
  • What is a preliminary class diagram?
  • If nouns on the use case script may become
    classes, what may verbs become on the class
    diagram?
  • What is an Object?
  • What is an Association on a class diagram?
  • What are the steps to create a Class Diagram?

20
Tutorial Exercise
  • Find the classes in the DVD rental shop example
  • (Start by underlining the nouns on the use case
    scripts)
  • Notice that you cant do class diagrams until you
    have done the Use Case Scripts bear this in
    mind for the assignment!
Write a Comment
User Comments (0)
About PowerShow.com