requirements analysis 1 use cases -> class diagrams moving from the user towards the system
Post on 20-Dec-2015
219 views
TRANSCRIPT
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?
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
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.
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
• 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
• 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
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
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?
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
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.
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.
• 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
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]
• What are the entity classes here?
• What are their attributes?
• How are they related?
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
• Can we add any more entity classes and relationships here?
List candidate entity classes
• Doctor
• Patient
• Appointment
• schedule
• Receptionist ?
• Treatment
• Payment?/Medical card
• Allergy?
• Condition?
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
Identify some attributes of each candidate class
• Patient?
• Doctor?
• Appointment?
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
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.
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.
Identify some operations..
• What can change the values of the attributes?
• What can change what the object is linked to?
Sample Structure class diagram
<entity>
Appointment
Date
Time
Reason
Type?
Doctor id#
Create ()
Cancel()
<entity>
Patient
Id#
Name
Address
Mobile
Phone
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..*
• Look at the example class diagram.
• How would the operations change the state of an object?
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.
Identify candidate entity classes
• Car
• Hire
• Customer
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
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
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..*
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.