Object-oriented modeling UML diagrams

Download Report

Transcript Object-oriented modeling UML diagrams

Karolina Muszyńska
Based on: http://www.csun.edu/~dn58412/IS431/IS431_SP13.html
G. Schneider , J.P. Winters „Stosowanie przypadków użycia”
S. Wrycza, B. Marcinkowski, K. Wyrzykowski „Język UML 2.0 w modelowaniu SI”


Why Object Modeling?
Object Concepts
◦ Class/Object, Attribute, Behavior,
Inheritance, Encapsulation, Message,
Polymorphism


Genesis of UML
UML Diagrams for Object-Oriented
Analysis
◦ Use Case Diagrams
2



Object modeling is a technique for identifying
objects within the systems environment and the
relationships between those objects.
Object-oriented analysis (OOA) techniques are
used to (1) study existing objects to see if they
can be reused or adapted for new uses, and (2)
define new or modified objects that will be
combined with existing objects into a useful
business computing application.
The Unified Modeling Language (UML) is a set of
modeling conventions (notations) to specify or
describe a software system in terms of objects.
3

Benefits:
◦ Break a complex system into manageable
components
◦ Create reusable components can be plugged
into other systems or use them as starting
points for other projects
◦ “Object-think” is more realistic !!!
4




An object is something that is or is capable of
being seen, touched, or otherwise sensed, and
about which users store data and associate
behavior.
A class is a set of objects that share common
attributes and behavior. A class is also referred
to as an object class.
Attributes are the data that represent
characteristics of interest about an object.
An instance (or object instance) of an object
consists of the values for the attributes that
describe a specific person, place, thing, or event.
5
Customer
Doe:Customer
Green:Customer
custNo
lastName
firstName
phone
street
city
state
custNo:123
lastName:Doe
firstName:Joe
phone:1234567
street:AnyStreet
city:AnyCity
state:AnyState
custNo:234
lastName:Green
firstName:Mary
phone:3456789
street:OtherStreet
city:OtherCity
state:OtherState
changeAddress()
changeAddress()
changeAddress()
6


Behavior (method, service) refers to those
activities that the object can do and which
correspond to functions that act on the object’s
data (or attributes).
Encapsulation is the packaging of data and
method together. It shields the internal working
of the object from the changes in the outside
system. It keeps the system from being affected
when changes are made to objects. It is the key
to reusability.

All an object needs to know is the set of methods that
other objects can perform and what message need to be
sent to trigger them.
7



Constructor to create a new instance of a class
Query to access and get info about the state of an
object but does not alter the state
Update to alter the state of an object and change
the value of its attribute(s).
8



A class supertype is an object class whose
instances store attributes that are common to one
or more class subtypes of the object.
A class subtype is an object class whose instances
inherit some common attributes from a class
supertype, and then add other attributes that are
unique to an instance of the subtype.
Inheritance means that methods and/or attributes
defined in an object class (superclass) can be
inherited or reused by another object classes
(subclasses).
9
Employee
Name
DOB
SSN
DateHire
CalSeniority()
Executive
Position
Location
DateAppoint
Salary
Update()
Foreperson
Factory
Station
DateAppoint
Wage Rate
Update()
Worker
Factory
Station
Machine
Wage Rate
Insert ()
10

Message is the information passed when one
object invokes one or more of another object's
methods (behaviors) to request information or
some action
Order
Customer
displayStatus(123)
OrderNo
OrderDate
OrderStatus
add()
change()
displayStatus()
11
 Polymorphism means “many forms.” In objectoriented techniques, it means that the same
message can be interpreted (and a behavior
may be completed) differently by different
objects/classes.
◦ Methods of the same name in different classes.
◦ Methods of the same name (but different
parameters) in the same class
◦ Insert(customer) is different from insert(inventoryitem) as different info need to be collected and
stored.
12

Methodological storm in object-oriented
solutions (1989-94)
◦ over 50 various object-oriented methods/solutions

Unified Modeling Language (UML)
◦ Third generation OO method
◦ An attempt to combine advantages of previous methods

Basis for the UML standard
◦ Object Modeling Technique (J. Rumbaugh) – UML
diagrams notation, analysis and design
◦ Object Oriented Analysis and Design (G. Booch) – analysis
and design
◦ Object Oriented Software Engineering (I. Jacobson) –
business modeling, use cases
13
14



Structure diagrams. A type of diagram that depicts
the elements of a specification that are irrespective of
time. This includes class, object, package, composite
structure diagrams and implementation diagrams:
component and deployment diagrams.
Behavior diagrams. A type of diagram that depicts
behavioral features of a system or business
process. This includes activity, state machine, and
use case diagrams as well as the four interaction
diagrams.
Interaction diagrams. A subset of behavior diagrams
which emphasize object interactions. This includes
sequence, communication, interaction overview, and
timing diagrams.
15
 Modeling the functions of the system (with a
use case diagram).
 Modeling the objects within the scope of the
system and their relationships (with class and
object diagrams for each use case, and then for
the integrated system).
 Modeling the interactions between objects to
complete a function/use case (with a sequence
diagram and activity diagram for each use case).
 Modeling the behavior / logic of the objects
(with a statechart diagram for each complex
class).
16
UML Diagrams
USE CASE DIAGRAM
CLASS DIAGRAM FOR USE CASE
“Create New Order”
Enter New Customer
CUSTOMER
ORDER
Create New Order
Order Clerk
SHIPMENT
:customer
Order Clerk
:order
:shipment
Create Order
Create Shipment
SEQUENCE DIAGRAM
FOR USE CASE
“Create
New Order”
CREATE ORDER
SHIP ORDER
STATECHART DIAGRAM
FOR OBJECT “Order”
17
 Use case modeling is the process of modeling a
system’s functions in terms of business events, who
initiated the events, and how the system responds to the
events.
 A use case is a complete sequence of related actions (a
scenario), both automated and manual, for the purpose
of completing a business function: What the system
must do.
 An actor represents an external entity that needs to
interact with the system to exchange information. An
actor is a user, a role, which could be an external
system as well as a person.
 A temporal event is a system event that is triggered by
time. (The actor of a temporal event use case is time.)
18
 Use Case Diagram is a functional description (use
cases, actors) of the entire system: functions
being supported by the system
 Use Case Diagram does NOT indicate data flows
or flows of information in and out the system
(they are identified later in interaction diagrams)
19
 An extension use case extends the functionality
of an original use case to add new behaviors or
actions to the basic course. An extension use
case can only be invoked by the use case it is
extending.
 An abstract use case contains typical course
steps that were common to two or more original
use cases. An abstract use case reduces
redundancy and promotes reuse.
20
Class registration
<<extend>>
Registration for
special classes
<<extend>>
Insufficient
prerequisites
“Class registration” is the basic course of actions.
On special occasions, “Registration for special classes”
and/or “Insufficient prerequisites” will be invoked.
Special cases add new data/behaviors to the normal case.
21
Reorder supplies
<<include>>
Track sales & inventory
<<include>>
Generate reports
“Track sales & inventory” includes “Reorder Supplies” and
“Generate reports”
22
Place order by
telephone
Client
Place order
Place order via
webpage
Sales
Representative
Prepare sales
report
“Place order by telephone” or “Place order via webpage”
are possible types of “Place order”
“Sales Representative” plays all roles of “Client”
23
Place order
Client
Check order
status
Salesman
Cancel order
Administer
warehouse state
DataBase
Administrator
CRUD (Create, Read, Update, Delete) type use cases are
used when application is meant to store data and one
actor interacts with it (e.g. database maintenance, order
management, etc.).
24
 Each use case should include documentation in the
form of scenarios
 Scenario is a sequence of actions documenting a
behavior
 Each use case should have at least the main scenario
but it is preferable to include the alternative
scenarios as well
 Both main and alternative scenarios precisely
describe the full functionality represented by a use
case
 Additional important elements of the use case
documentation include: pre-conditions and postconditions
25
 Identify actors (look at the sources and
destinations of major inputs and outputs)
 Identify use cases (major system functions)
 Identify the system boundary
 Identify associations between actors and use cases
 Identify additional associations between use cases
(“extend”, “include”)
 Identify inheritance relationships among use cases
and actors
26