UML – Unified Modeling Language ● ●
●
Visual language. Used to model systems and system development –
system requirements
–
system structure
–
system behaviors
Object-Oriented –
but this doesn't mean implementation must be OO. UML Intro
1
Software Engineering History ●
In the old days : structural programming –
●
procedures, functions, collections of functions, etc.
Structured Analysis and Design –
based on some formal design documents ●
●
data flow, state models, task diagrams
OOP and Object Oriented Design –
Booch, OMT, OOSE: competing methods. ●
unified as "UML"
UML Intro
2
Why learn UML? ●
●
It's good to study formal design techniques, models, languages, etc. UML is an industry standard. –
●
●
lots of tools are available.
Many large software systems are modeled using UML in the real world. It's fun to draw pictures with stick figures!
UML Intro
3
Software Methodology ●
●
The process used (by designers, programmers, testers, managers, etc) to develop a software system. UML is not tied to any specific methodology –
although it is often associated with specific approaches an processes.
UML Intro
4
System development activities ●
Requirements gathering
●
Requirements analysis
●
Design (to meet requirements)
●
Implement (to the design)
●
●
Test (make sure implementation meets requirements) Deploy (sell!).
UML Intro
5
The Waterfall Methodology ●
●
●
Each step is completed in detail for the entire system before moving to the next step.
Design Implementation
The goal is to cover every detail and consider all possibilities before design and implementation.
Test Deploy
For some types of activities this is necessary! ●
●
Requirements
Consider sending a man to the moon. Once the rocket has launched you can't decide to switch engine designs.
In general this model is not realistic for many type of software systems (won't lead to low-cost/high-quality). UML Intro
6
Iterative Approach ●
●
Entire cycle is repeated multiple times. –
it's not necessary to complete all steps each iteration.
–
Can start with base functionality (requirements) and build upon this incrementally.
General idea is to start with a coarse set of models, then iteratively refine and rework the models. –
The hope is that the process converges! UML Intro
7
Spiral Requirements Requirements
Test
Test
Design
Design
Design
Test
Requirements
Implement
Implement
Implement
UML Intro
8
UML and process ●
UML can be used to document each of the steps: –
requirements as use-case diagrams
–
design as OO models and structural models
–
Implementation (typically as OO, but doesn't need to be).
–
Tests
UML Intro
9
UML ●
●
Alphabet: symbols (drawing primitives) and strings. Words: grouping of elements from alphabet. –
smallest unit that has meaning
–
Two kinds: ●
Concepts –
●
drawn as rectangles
Relationships (between concepts) –
drawn as lines connecting two concepts that are related.
UML Intro
10
Sentences ●
A diagram that depicts the relationship(s) between some concepts is a UML sentence. Teach Teacher
Student
Evaluate Teacher
Student Ignore
Teacher ●
Student
Implied order when reading is left-to-right, topto-bottom UML Intro
11
UML and Objects ●
UML uses objects and classes to model concepts.
●
Relationships are called associations in UML.
●
A class is the definition of a type of object.
●
Student is a class –
Joe Smith could be an object of type Student
–
Usually shown as "Joe Smith:Student"
UML Intro
12
Attributes ●
Objects can have attributes –
●
the things the object knows
A class can include a list of attributes: Student Name RID Term Project Grade
UML Intro
class name
attribute names
13
Objects and attributes ●
For an object, each attribute can have a value. –
typically we only list the attributes relevant to the context of the diagram. Student
Name RID Term Project Grade
Joe Smith:Student Name = "Joe L. Smith" Term Project= E-Bay Clone
UML Intro
14
Classes and operations (methods) ●
●
A class can include a set of operations –
specification of what objects of the class can do
–
processing.
Keep in mind that UML classes are not tied to any implementation method –
●
we don't include code or even formal prototypes.
Keep in mind that the operations shown in any diagram are only those relevant to that diagram (to the context in which the class is displayed). UML Intro
15
Class Examples Teacher
name attributes
Give Lecture Assign project Induce Sleep Grade project
operations
UML Intro
Student Term Project Caffeine Intake Work on project Sleep
16
Example Diagram Student
Teacher
Caffeine Intake Prepare Lecture Induce Sleep
Sleep
Owns
Soda Machine
Needs
Location Price
UML Intro
17
Messages ●
Communication between classes is modeled as messages –
●
Communication between objects is called stimulus –
●
A message is a type of interaction between objects of specific classes.
an instance of a message between two objects.
A message models invocation of an operation. UML Intro
18
Stimulus ●
Sender object is called the client
●
Receiver object is called the supplier –
●
A single diagram can include many messages –
●
supplies the processing of the operation. the order is specified (it often is important!).
A messages (stimulus) is drawn as an arrow pointing from the sender to the receiver labeled with the message order and operation. UML Intro
19
Example 4: Wake Up
Teacher 1: Prepare
Student
2: Present
Lecture 3: Induce Sleep
UML Intro
20
Another Example 4: Wake Up
Dave:Teacher 1: Prepare
:Student
2: Present
UML:Lecture 3: Induce Sleep
UML Intro
21
Object Oriented Modeling Abstraction Encapsulation Generalization Polymorphism UML Intro
22
Abstraction ●
Both concepts and relationships
●
Reduce complexity
●
●
–
Only need to provide details of what is important to context.
–
ignore (or gloss over) details that are not important to the context.
Classes and Associations are general abstractions. Objects and Links are specific abstractions. UML Intro
23
Encapsulation ●
Combining attributes and operations into a single (abstract) entity. –
●
hides the details related to implementation
Information hiding –
Treat objects simply as entities with visible attributes and operations.
–
internal state/methods are not relevant outside of the object/class.
UML Intro
24
Generalization ●
●
Classes can be general (containing attributes and/or operations relevant to many types of concepts) A class can be specialized version of a general class (sometimes more than one general class). –
●
Inheritence
Define attributes and operations that are common to many classes in one general class. UML Intro
25
Generalization Example Person Name Address Email Sleep Wakeup Work
Student
Teacher
Term Project Grade
Soda Machine Office UML Intro
26
Polymorphism ●
Operations common to all specializations of a class allow us to refer to the operation universally. –
●
the actual methods (implementation) may be very different.
Polymorphism allows us to refer generically to an operation, knowing that the details of the operation depend on the specific type of object involved. UML Intro
27
Polymorphism Example Person Name Address Email
Any object that is of a class that is a kind of Person (a specialization of Person) has a Work method. We can consider the operation Work no matter what kind of Person object we have.
Sleep Wakeup Work
Student
Teacher
Term Project Grade
Soda Machine Office
Work
Work UML Intro
28
Exercise ●
●
Develop a UML diagram that describes a simple e-commerce system. Potential Concepts: –
User
–
Product
– –
Shopping Cart Shopping Cart Entry
●
●
Be as complete as you can. Include –
attributes
–
operations
–
associations
UML Intro
29