cosc 3351 software design an introduction to uml (ii)gabriel/courses/cosc3351_s08/sd_06_uml2.pdf ·...
TRANSCRIPT
1
Edgar Gabriel
COSC 3351
Software Design
An Introduction to UML (II)
This lecture contains material from:
http://dn.codegear.com/article/31863
Edgar Gabriel
Spring 2008
COSC 3351 – Software Design
Edgar Gabriel
Packages
• Classes can be grouped into packages
2
COSC 3351 – Software Design
Edgar Gabriel
Sequence diagrams (I)
• A sequence diagram is an interaction diagram that
details how operations are carried out -- what messages
are sent and when.
• Sequence diagrams are organized according to time.
The time progresses as you go down the page.
• The objects involved in the operation are listed from
left to right according to when they take part in the
message sequence.
COSC 3351 – Software Design
Edgar Gabriel
Sequence diagrams (II)
3
COSC 3351 – Software Design
Edgar Gabriel
Example: course enrollment system
• Problem description:
– Users must be able to view a menu of available courses
and select a course
– Once selected, a pop-up allows to enter: name, phone,
fax and e-mail address
– User can select payment option: check, purchase order,
credit card
– Once all information is provided, user has to click on
submit button -> another screen pops up summarizing all
information and instructs user to print, sign and fax the
copy
– E-mail is sent automatically to an Enrollment Clerk (EC)
about the user and the subscription
COSC 3351 – Software Design
Edgar Gabriel
Example: course enrollment system (II)
– System knows maximum number of students for each
class and marks classes as ‘sold out’ if limit is reached
– EC can e-mail all students enrolled in a course by bringing
up a special form -> select course, type message
– EC can bring up a form that shows status of all students
for all courses that have already been taught.
• Status will indicate whether student was attending
and whether student has payed
4
COSC 3351 – Software Design
Edgar Gabriel
Identifying Actors
• Enroller: This actor enrolls a student in a course
• Enrollment Clerk: This actor receives e-mail
notification of each enrollment. It also sends e-mail
notices to students and receives reports about
enrollments and payments
• Student: This actor receives e-mail notification of
enrollment and e-mail notifications from the
Enrollment Clerk. The student attends the courses it is
enrolled in.
COSC 3351 – Software Design
Edgar Gabriel
Use case 1
• Use case 1: View Menu of
choices
– Enroller requests list of
courses
– System displays list of
courses
– Included are name, place,
time and cost of the course
– List will also show number
of students allowed and
currently enrolled
View Menu
of choices
Enroller
5
COSC 3351 – Software Design
Edgar Gabriel
Use case 2• Use case 2: Enroll in a course
– Enroller views menu of courses
(Use case 1)
– Enroller selects course
– System prompts for name,
phone, fax, email, address and
preferred payment
• Extension point: fill out
payment method
– Other use cases will be
extending this use case
– Used whenever there are many
alternatives within a part
View Menu
of choices
Enroller
Enroll in a course
Extension points:fill out payment
method
Student
<<include>>
Enrollment Clerk
COSC 3351 – Software Design
Edgar Gabriel
Use case 2 & 3
• Use case 2.1: pay by purchase order
• Use case 2.2: pay by check
• Use case 2.3: pay by card
• Use case 3: email messages to
students
Enroll in
course
Pay by PO Pay by check Pay by card
<<extend>>
Email msgs.
to studentsEnrollment Clerk
Student
6
COSC 3351 – Software Design
Edgar Gabriel
Use case 4
• Use case 4: set attendance
– Select a class and a student
that is enrolled in that class
– System presents student and
shows whether the student
attended the class and
payment has been received
Enrollment Clerk
Set
attendance
COSC 3351 – Software Design
Edgar Gabriel
Use case 5
• Get student status:
– EC selects student
– Extension point: select student of
interest
• Use case 5.1: select students in a course
– List all courses, EC selects a course
– System shows all students in the
course
• Use case 5.2 select unpaid students
– EC indicates that the system should
select all unpaid students
Get student status
Extension points:Select students of
interest
Select students
in course
Select unpaid
students
<<extend>>
Enrollment Clerk
7
COSC 3351 – Software Design
Edgar Gabriel
System Boundary Diagram
View Menu
of choices
Enroll in
course
Email msgs.
to students
Set
attendance
Get student status
Enrollment Clerk
Student
Enroller
<<include>>
COSC 3351 – Software Design
Edgar Gabriel
Domain model
• Set of diagrams that help to define the terms that
appear in the use cases (descriptive tool)
• Show key objects within the problem and their
relationships
• The domain model is not necessarily the model of the
software to be built!
• We will depict domain models using the <<type>>
stereotype in the class diagrams
– UML allows to substitute different icons for different
stereotypes (e.g. you could represent a domain model as
a cloud to clearly distinguish them from classes)
8
COSC 3351 – Software Design
Edgar Gabriel
Domain Model (I)
• 1. Abstraction: The course catalog
– List of courses that are offered
– Problem with this abstraction: the same model could be
offered multiple times at different locations
• Need to separate the course from the schedule (date,
location, instructor)
<<type>>
Course Catalog
Add Course()
Remove Course()
<<type>>
Course
Fee: Currency
Enrollment limit: integer
Current enrollment: integer
0..n
COSC 3351 – Software Design
Edgar Gabriel
Domain Model (II)<<type>>
Course Catalog
Add Course()
Remove Course()
<<type>>
Course
Fee: Currency
Enrollment limit: integer
0..n
<<type>>
Session
Session date
Current enrollment
instructor
Add Student()
Remove Student()
<<type>>
Session Schedule
Add Session()
Remove Session()
0..n
<<type>>
Student
Paid: bool
Attended: bool
enrolled in
0..n
schedules
offers
teaches
9
COSC 3351 – Software Design
Edgar Gabriel
What we’ve learned from the domain
model• Use cases employ the wrong language!
– Course catalog and courses have to be replaced in the use
cases by session schedules and session
– Some use cases have been left out
• Need to maintain Course Catalog and Session Schedule
• Courses and Sessions need to be added and removed
from Course Catalogs/Session Schedules
• Creating the Domain Model helps us understand the
problem
COSC 3351 – Software Design
Edgar Gabriel
Deciding the Architecture/Software
Platform• Choices
– A Web-based CGI application
– A database application
– Visual XYZ
– Write everything from scratch in C
• -> we choose CGI for this case
10
COSC 3351 – Software Design
Edgar Gabriel
Web architecture
• Need to decide on the number of web-pages, what CGI
scripts shall be invoked etc…
<<cgi>>
Session Menu
Generator
<<html>>
Session Menudepends
COSC 3351 – Software Design
Edgar Gabriel
Web Architecture (II)
<<html>>
Session Menu
<<cgi>>
Session Generator
<<cgi>>
Enrollment Form Generator
<<html>>
Enrollment Form
<<cgi>>
Enroll
<<html>>
Enrollment
Error
<<html>>
Enrollment
Confirmation
<<html>>
Banner
11
COSC 3351 – Software Design
Edgar Gabriel
Database Interface Layer
• Each CGI program must have access to the data
representing students, classes, schedules etc.
– We call it the training database
• To keep the access independent of a particular data
base, we introduce a Database Interface Layer (DIL)
Training
Application
Training
DIL Training
Databasedepends depends
COSC 3351 – Software Design
Edgar Gabriel
Database Interface
• Classes within the training application need to access
the database
• This will be accomplished through a set of interfaces
inside the Training Application
• Interfaces are implemented by classes in the DIL
package
12
COSC 3351 – Software Design
Edgar Gabriel
<<type>>
Session Schedule
<<interface>>
Session Schedule
+GetSessionIterator():iterator<Session>
DIL:: Session Schedule DIL:: Session DIL:: Course
<<interface>>
Session
+GetCourse():Course
+GetDate(): Date
+GetLocation(): string
+GetTime(): Time
<<interface>>
Course
+GetCourseName():string
+GetCost():float
<<type>>
Session
<<type>>
Course
imports
realizes
COSC 3351 – Software Design
Edgar Gabriel
Session Menu Generator
• Corresponds to the 1st use case
• Goal: Build an HTML representation of a session
schedule
– Merge an HTML template with the actual data from a
session schedule
– Program will use the SessionSchedule interface to access
Session and Course instances in the database, in order to
get names, times, locations and fees.
13
COSC 3351 – Software Design
Edgar Gabriel
: Session Menu
Generator
: HTML Template
: Session Schedule
: iterator<session>
: Session : Coursecreate
GetSessionIterator
GetNext
GetCourse
GetTime, GetLocation
GetCourseName, GetCost
SessionIterator
Session
Course
Time, Location
Name, Cost
For each session in iterator<session>
Insert (“Schedule”,
lineItem
generate
destroydestroy