Title: UML and the Software Development Process
1UML and the Software Development Process
- expanding the design process
- UML Use Cases
- UML class diagrams
2Software Development
- a software development process (or method or
methodology) specifies who is doing what when,
and how to transform the stakeholders'
requirements into a software system - the key to communication between people involved
in the process is a modeling language usually a
graphical notation for expressing e.g. class
designs - we use UML, the Unified Modeling Language "A
graphical language for visualising, specifying,
constructing and documenting the artifacts of a
software-intensive system" - UML has 9 types of diagram, but we will look at
only 3 - we have been using these informally in lectures
3Analysis Design Implementation
- Analysis
- establish the rationale, scope and purpose
- build a model of the problem domain (not the
software) - use case diagrams, class diagrams, sequence
diagrams - Design
- decide on the software classes and interfaces
- class diagrams, sequence diagrams and GUI
mock-ups - Implementation
- write code for each class, carry out testing
- class diagrams, sequence diagrams
4Analysis problem domain class identification
- "underline the nouns in your requirements
documentation" - good in theory, but in practice ...?
- problem domain classes will be revealed
- in discussion with domain experts (recurring
terms, terms they define, ...) - by seeing physical manifestations (real order
forms,...) - from existing software systems
- from refining your diagrams (e.g. new classes
sometimes arise from what you initially thought
were relationships)
5Analysis scenarios
- a scenario is one thing that can happen when
running the software - Example 2 scenarios for an online CD store
- the user logs on to the system, browses a list of
CDs, spots the one she wants, adds it to basket,
proceeds to "checkout", enters her credit card
details, confirms the purchase, system checks
authorisation, confirms the sale, queues CD for
packing and dispatch - the user logs on to the system, ..., enters
credit card details, confirms the purchase,
authorisation fails, user exits the system
6Analysis Use case
- a use case is a set of scenarios tied together by
a common user goal - Example "buy a CD" use case consists of the two
previous scenarios (success, fail credit card)
plus others - Typically, a use case will have one "as expected"
scenario, plus a number of related scenarios for
failures or alternative paths to success - You must decide which scenarios fit into a use
case, and which require new use cases
7Analysis Use Case text description
- Buy a CD
- Main Success Scenario
- Customer logs on
- Customer browses list
- Customer selects CD
- Customer proceeds to checkout
- Customer enters credit card details
- Credit company authorises
- Dispatcher queues for delivery
Extensions 3a Customer quits 6a credit
refused 6a1 customer may re-enter or quit
8Analysis Use Case Diagrams
stock controller
system engineer
authorisation
credit company
customer
dispatcher
9Analysis using Use Cases
- the Use Case diagram is a formal part of UML
- an actor is a role a user plays with respect to
the system - one human user can be multiple actors
- actors can be external systems
- identifying the actors helps decide on the use
cases - one use case can include another
- one use case can generalise another
- Use cases are extremely useful in analysis, and
help to guide the design phase - the text descriptions are informal
- you can include many different types of
requirement - the text is more useful than the diagram
10Design
- draw a class diagram showing software classes
- "problem domain" classes may have corresponding
software classes - boundary classes mediate between the software and
its clients - control classes coordinate workflow between
objects - interfaces hide classes in which change is
anticipated - include navigability arrows on associations
- draw sequence diagrams
- draw GUI mock-ups
11Software class identification
- a software class is an abstraction around data
- state (attributes/instance variables) and
behaviour (operations/instance methods) - identify candidate classes from design patterns,
code libraries (reuse!), data structures
textbooks and courses, experience, discussion
with others, etc - candidate classes that are not abstractions of
data should arouse suspicion (unless they are
control classes) - classes with names that are processes
- classes with no attributes or no methods
12Class diagrams
- a class diagram shows classes and their
relationships - association a customer may have a purchase
history - subtypes a DVD is a type of product
- they model parts of the structure of your problem
domain or software system - you don't have to show all attributes or
operations concentrate on the important ones
that help understanding - can specify type, visibility, parameters and
return type
13Class diagram examples
CD getTitle getName match
CD title name getTitle getName match
CD
CD -title String -name
String getTitle()String getName()String match
(String)boolean
14Class diagrams Association
- Association objects of class A are connected to
objects of class B - shown by a solid line between the classes
- may have a name
- open arrow indicates navigability (A -gt B means A
"knows" it links to B, but B doesn't know about
A) - can also show multiplicity ( Am -gt nB means A
links to n Bs, and B links to m As) - i..j means links to between i and j items
- means links to any number of items
15Class Diagrams Generalisation
- Generalisation every B is a special kind of A
- shown by a solid line with a closed white arrow,
pointing from subtype to parent type - use italics for abstract classes and abstract
methods - also able to show the implements relationship
- shown by a dashed line with a closed white arrow
- interfaces are shown as a circle, or like a
class, but with "ltltinterfacegtgt" before the class
name
16Class diagram online store specification
1
1
1
1
Store
Customer
StoreGUI
1
1
BasketItem
1
Item
CD
DVD
Book
17Alternative store specification
1
1
1
1
Store
Customer
StoreGUI
1
1
1
1
1
1
Catalogue
Basket
History
1
1
1
1
BasketItem
Item
CD
DVD
Book
18detailed specification
1
1
1
1
Customer -id int -basket
ArrayListltBasketItemgt -history
ArrayListltBasketItemgt Customer(int) getId()
int getBasket() ListltBasketItemgt getHistory()
ListltBasketItemgt readFromFile(Store)
void saveToFile() void toString() String
StoreUDGui -customer
Customer -store Store -ud UserDialog StoreUDGui
(Store) displayBasketItems(ListltBasketItemgt,
String)
void displayCatalogueItems(ListltCatalogueItemgt,
String)
void findInCatalogue(ListltCatalogueItemgt,
int) CatalogueItem findInB
asket(ListltBasketItemgt
int) BasketItem addItemToBasket()
void changeItemDetails() void removeItemFromBas
ket() void searchCatalogue()
void searchBasketItems(ListltBasketItemgt)void pu
rchaseBasket() void interactWithUser() void
Store -catalogue
ArrayListltCatalogueItemgt -customer
Customer -nextId int Store() loginCustomer(Cust
omer) boolean logoutCustomer()
void getNextIdWithoutIncrementing()
int getNextId() int getCatalogue()
ListltCatalogueItemgt getCustomer()
Customer getItem(int) CatalogueItem -readCatalog
ueFromFile() void -readNextUserIDFromFile()
void toString() String
1
1
1
BasketItem -itemCatalogueItem -n
umber int BasketItem(CatalogueItem,int) setNumb
er(int)void getItem() CatalogueItem getNumber(
) int saveToFile(PrintWriter) toString()
String matches(String) boolean
CatalogueItem -title
String -number int -price double CatalogueItem(
String,int,double) getTitle()
String getNumber() int getPrice()
double toString() String matches(String)boolea
n
Book -author
String -publisher String -isbn
String Book(String,int,double,String,String,Strin
g) getAuthor() String getPublisher()
String getIsbn() String readFromFile(BufferedRe
ader) Book
CD -artiste
String -recordLabel String CD(String,int,double,
String,String) getArtiste() String getRecordLab
el() String readFromFile(BufferedReader) CD
19detailed specification (fragment)
1
BasketItem -itemCatalogueItem -n
umber int BasketItem(CatalogueItem,int) setNumb
er(int)void getItem() CatalogueItem getNumber(
) int saveToFile(PrintWriter) toString()
String matches(String) boolean
CatalogueItem -title
String -number int -price double CatalogueItem(
String,int,double) getTitle()
String getNumber() int getPrice()
double toString() String matches(String)boolea
n
20Next lecture ...
- UML for specifying control flow