CH 7 - CRC Cards Class Diagram Object Diagram

39
Slide 1 Information Systems Development Information Systems Development CSM03 Autumn Semester CSM03 Autumn Semester 2008 2008 Dr. Jonathan Y. Clark Email: [email protected] Course Website: www.computing.surrey.ac.uk/courses/csm03/ISDmain.htm

Transcript of CH 7 - CRC Cards Class Diagram Object Diagram

Page 1: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 1

Information Systems DevelopmentInformation Systems DevelopmentCSM03 Autumn Semester CSM03 Autumn Semester 20082008

Dr. Jonathan Y. ClarkEmail: [email protected]

Course Website: www.computing.surrey.ac.uk/courses/csm03/ISDmain.htm

Page 2: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 2

Course Textbook:Course Textbook:Systems Analysis and Design With UML 2.0Systems Analysis and Design With UML 2.0

An ObjectAn Object--Oriented Approach, Second EditionOriented Approach, Second Edition

Chapter 7: Structural Modelling

Page 3: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 3

Adapted from slides © 2005John Wiley & Sons, Inc.

Page 4: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 4

Key Ideas

A structural or conceptual model describes the structure of the data that supports the business processes in an organization..The structure of data used in the system is represented through CRC cards, class diagrams, and object diagrams.

Page 5: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 5

STRUCTURAL MODELS

Page 6: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 6

Purpose of Structural Models

Reduce the “semantic gap” between the real world and the world of softwareCreate a vocabulary for analysts and usersRepresent things, ideas, and concepts of importance in the application domain

Page 7: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 7

Classes and Objects

Class – Template to define specific instances or objectsObject – Instantiation of a classAttributes – Describes the objectOperations/Methods –specify what an object can do

Page 8: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 8

Helpful Hint….’Compile’

C ClassesO Objects M Methods and MessagesP Polymorphism I Inheritance(Last, but not least)E Encapsulation

Page 9: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 9

Classes and Objects

Page 10: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 10

Encapsulation and Information Hiding

Encapsulation combination of data and process into an entity

Information HidingOnly the information required to use a software module is published to the user

Reusability is the Key Pointan object is used by calling methods

Page 11: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 11

Inheritance

Superclasses or general classes are at the top of a hierarchy of classesSubclasses or specific classes are at the bottomSubclasses inherit attributes and methods from classes higher in the hierarchy

Page 12: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 12

Class Hierarchy

Page 13: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 13

Inheritance

Page 14: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 14

Classes

Templates for creating instances or objects

Concrete (can have real instances)Abstract (only exists to hold subclasses)

Typical examples:Application domain, user interface, data structure, file structure, operating environment, document, and multimedia classes

Page 15: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 15

Attributes

Units of information relevant to the description of the classOnly attributes important to the task should be included

Page 16: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 16

Operations (Methods)

Action that instances/objects can takeFocus on relevant problem-specific operations (at this point)

Page 17: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 17

Relationships

GeneralizationEnables inheritance of attributes and operations [...is a kind of...]

AggregationRelates parts to the whole [..is a part of..]

AssociationMiscellaneous relationships between classes

Page 18: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 18

CLASS-RESPONSIBILITY-COLLABORATION CARDS

Page 19: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 19

Responsibilities and Collaborations

ResponsibilitiesKnowingDoing

CollaborationObjects working together to service a request

Page 20: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 20

A CRC Card

Page 21: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 21

Back of CRC Card

Page 22: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 22

CLASS DIAGRAMS

Page 23: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 23

Example Class Diagram

Page 24: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 24

Class Diagram Syntax

A CLASS

AN ATTRIBUTE

AN OPERATION

AN ASSOCIATION

Class 1

-attribute

+operation ()

Attribute name/derived attribute name

operation name ()

1..* 0..1______verb phrase____

Page 25: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 25

More on Attributes

Derived attributes/age, for example can be calculated from birth date and current date

Visibility+ Public (not hidden)# Protected (hidden from all except immediate subclasses)- Private (hidden from all other classes)

Page 26: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 26

More on OperationsConstructor

Creates object Destructor

Removes objectQuery

Makes information about state available

UpdateChanges values of some or all attributes

Page 27: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 27

Generalization and Aggregation

Generalization shows that a subclass inherits from a superclass

Doctors, nurses, admin personnel are kinds of employees

Aggregation classes compriseother classes

Health team class comprised ofdoctor, nurses, admin personnel classes

Page 28: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 28

Page 29: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 29

More on Relationships

Class can be related to itselfMultiplicity

Exactly one, zero or more, one or more, zero or one, specified range, multiple disjoint ranges

Association class (class describing a relationship)

Page 30: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 30

Multiplicity

Page 31: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 31

Page 32: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 32

Simplifying Class Diagrams

The view mechanism shows a subset of informationPackages show aggregations of classes (or any elements in UML)

Page 33: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 33

Object Diagrams

Page 34: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 34

CREATING CRC CARDS AND CLASS DIAGRAMS

Page 35: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 35

Object IdentificationTextual analysis of use-case information

Nouns suggest classesVerbs suggest operations

Creates a rough first cutCommon object listIncidentsRoles

Page 36: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 36

PatternsUseful groupings of classes that recur in various situationsTransactions

Transaction classTransaction line item classItem classLocation classParticipant class

Page 37: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 37

Steps for Object Identification and Structural Modelling

1. Create CRC cards by performing textual analysis on the use-cases.

2. Brainstorm additional candidate classes, attributes, operations, and relationships by using the common object list approach.

3. Role-play each use-case using the CRC cards.

4. Create the class diagram based on the CRC cards.

5. Review the structural model for missing and/or unnecessary classes,attributes, operations, and relationships.

6. Incorporate useful patterns.

7. Review the structural model.

Page 38: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 38

CD Selections – a CD Marketing Company

Page 39: CH 7 - CRC Cards Class Diagram Object Diagram

Slide 39

Summary

CRC cards capture the essential elements of a class.Class and object diagrams show the underlying structure of an object-oriented system.Constructing the structural model is an iterative process involving: textual analysis, brainstorming objects, role playing, creating the diagrams, and incorporating useful patterns.