Top Banner
Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system
31

Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Requirements Analysis 1

Use Cases -> Class Diagrams

Moving from the user towards the system

Page 2: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Requirements Specification

• Requirements Gathering : asking questions, interviewing, observation, documents, prototypes

• Requirements documentation : use case diagrams, templates, architecture diagrams

• Requirements verification – have I got it right?

Page 3: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Requirements Analysis

• more detailed picture of requirements• organised to facilitate software design

• A requirements model models requests in terms of what the system can do.

• It describes the internal structure and behaviour of the proposed system

Page 4: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

From Use Case to UML Class DiagramsUse Case Realisation includes identifying a

set of classes with an understanding of how they work together to provide the functionality of the use case.

UML Class Diagram -a conceptual model that can be easily translated into software components but is language/platform independent.

Page 5: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

First of all......

• We need to get a static structural view of the system.

• Entity – Relationship Modelling techniques can help here.

• Identify entities (objects), their attributes, and relationships

Page 6: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

• From the detail in the use case diagrams and set of use case templates we can identify the main objects (classes) in the system.

• Their attributes – what describes them

• Their behaviour/methods – what events can change the state of the object

Page 7: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

• An object’s state changes when there is a change in:

• the value of one of its attributes or

• in the objects that it is related to

Page 8: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Flight

• Flight number• Capacity• Origin• Destination• Date/time• Number of passengers

booked• Number of passengers

checked in• passengers booked• passengers checked in

Scheduleflight (date/time)

Changecapacity(capacity)

Book(passenger)

Checkin(passenger)

Cancelbooking(passenger)

Reroute(origin, destination)

attributes Operations/methods

Page 9: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

What objects could a flight be related to?

• Passenger : a passenger can travel on many flights,

• a flight has many passengers

• a flight has many Bookings

• a booking is for one flight

• a booking is for one passenger

Are there lots of types of flight – if so maybe examine if we can use inheritance?

Page 10: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Types of Relationship (OOD)

1. Generalisation/specialisation (inheritance)

...ISA, IS-A-KIND-OF

A doctor is a staff member is a person

2. Aggregation/decomposition: collection or assembly- a-part-of, has-parts

3. Association e.g. A patient has many apppointments, an appointment is for one patient

Page 11: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

3 main types of classes (stereotypes)

• Entity class – what the system keeps information about : things, concepts etc.

• Boundary class (user interface)

• Control class (logic of use case)

These 3 types of class collaborate to realise the use case.

Page 12: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Class Attributes

• Relevant items of data that the system needs to keep track of e.g. ID, Name, address, phone, mobile, medical cardno/ money owed etc.

• If these are multiple, you might need another related class e.g. A patient has many appointments, treatments, prescriptions etc.

Page 13: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

• Identifying entity classes, attributes and relationships is similar to database E-R diagrams

We show multiplicity in relationships

• E.g. a patient must have one doctor

• A doctor can have 0..100 patients

Page 14: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Example : Doctor’s surgery

Use Case : Make appointment

• Patients wants appointment. • Receptionist looks at doctor’s schedule for free

appointments. • Receptionist books the appointment • Patients have family doctor• Patients fill in a form with their personal details

[name, address, phone, mobile, email, allergies, ongoing conditions]

Page 15: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

• What are the entity classes here?

• What are their attributes?

• How are they related?

Page 16: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Some more information...

Use case: Record Treatment

• Doctor brings up their personal details on the screen.

• makes a diagnosis and enters into their treatment record.

Use Case : Record payment

• Patient pays or gives medical card no

Page 17: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

• Can we add any more entity classes and relationships here?

Page 18: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

List candidate entity classes

• Doctor

• Patient

• Appointment

• schedule

• Receptionist ?

• Treatment

• Payment?/Medical card

• Allergy?

• Condition?

Page 19: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Classes specify attributes and operationsAttributes

• Describe classes

• Each object has its own

• May or may not change during the life of an object.

Operations/methods

Describe class behaviour

Page 20: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Identify some attributes of each candidate class

• Patient?

• Doctor?

• Appointment?

Page 21: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Object state

• When a piece of software is run actual objects or instances of classes are created.

• An object’s current state can be described by the values of its attributes and what objects it is currently linked to.

• The state of an object can be updated by sending it a message (invoking a method).

• Objects can be destroyed• State diagrams show possible changes in state of

an object

Page 22: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Links and Associations

• A link is a logical connection between 2 objects: Allowable links shown by association between 2 classes.

e.g. Jenny has an appointment scheduled for 3.30 with her doctor and another at 4.30 with the nurse.

• Doctor Deeney has 10 appointments.– Links represent real world connections.– Associations represent the possibility of links.

Page 23: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Operations ( methods)

• Elements of common behaviour shared by all instances of a class (objects)

• They are eventually implemented by methods in a programming language.

• The state of an object can only be changed through invoking an operation sending a message to the object.

Page 24: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Identify some operations..

• What can change the values of the attributes?

• What can change what the object is linked to?

Page 25: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Sample Structure class diagram

<entity>

Appointment

Date

Time

Reason

Type?

Doctor id#

Create ()

Cancel()

<entity>

Patient

Id#

Name

Address

Mobile

Phone

Email

Doctor id#

Medical card#

Insurance#

Account balance

Create patient()

Assigndoctor()

Chargepatient(amount)

Makeappointment()

Viewappointment()

Pay(amount).

Delete()

1

0..*

Has 0 or more..

<entity>

Doctor

Doctor id#

Assign_patient

Create ()

Deletel()

View_patients()

View-appointments(day);

1

0..*

1

0..*

Page 26: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

• Look at the example class diagram.

• How would the operations change the state of an object?

Page 27: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Example 2 : Car Hire

Customer comes to hire a car.

Specify category -small, medium luxury

Find details of available cars

Car is uniquely identified by reg#

Customer’s details and details of the hire typed: e.g. id # and type; payment method, duration, Pick-up, and drop-off points. If . drop-off and pick-up points are different surcharge of £40.

Page 28: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Identify candidate entity classes

• Car

• Hire

• Customer

Page 29: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Clearly specify their relationships

• Car can have many Hires

• A hire is for one car

• A customer can have many hires

• A hire is for one customer

Page 30: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Sample Structure class diagram

<entity>

Hire

Date/time of hire

Date/time of pickup

Date/time return due

Pickup point

Dropoff point

car

Create ()

Assigncar(car)

Cancel()

<entity>

Customer

Id#

Name

Address

Mobile

Phone

Email

balance

Charge (amount)

Pay(amount).

1

0..*

Has 0 or more..

<entity>

Car

reg#

Make

Model

Status (hired,available etc.)

Create ()

Noteaccident()

Hire()

1

0..*

Page 31: Requirements Analysis 1 Use Cases -> Class Diagrams Moving from the user towards the system.

Online DVD Library • Customers can register with an online DVD library by entering their

email address and personal details [Customer email and password, Customer Name, Customer address].

• To borrow a DVD a customer logs onto the system, using their email address and password, browses a list of DVDs available and selects a DVD.

• DVD details contain the following: DVD Id, DVD title, cost of hire per night.  

• The system checks if a copy of the DVD is available, and lets the customer know. If one is available they can order the DVD. When they do this, they must then pay by credit card. Once this payment is processed, a loan record is generated and a loan number is given to the customer.  

• The loan record contains loan number, customer number, DVD id, Copy no., date of loan, date dispatched, and date returned.