uml introduction
DESCRIPTION
UML Introduction. Alexandre Lomovtsev, Natalia Shatokhina. Frameworks and Design Patterns. John Hautzinger, Sae Rom Hong. CS537 – Fall 2010 CSULA. UML Introduction. Alexandre Lomovtsev, Natalia Shatokhina. What is UML?. - PowerPoint PPT PresentationTRANSCRIPT
UML UML IntroductionIntroduction
Frameworks and Design PatternsFrameworks and Design Patterns
Alexandre Lomovtsev, Natalia Shatokhina
John Hautzinger, Sae Rom Hong
CS537 – Fall 2010
CSULA
UML UML IntroductionIntroduction
Alexandre Lomovtsev, Natalia Shatokhina
What is UML?What is UML?
is a complete Language for capturing knowledge (semantics) about a subject and expressing knowledge (syntax) regarding the subject for the purpose of communication
applies to Modeling – process of understanding a subject (or a system)
is Unified – remaining the same at each stage of development
BackgroundBackground
1965 - the first object-oriented programming language, Simula I, was introduced
Object-oriented design began to rapidly grow
Numerous competing object-oriented design methods and modeling languages over 50 modeling languages
Dominate modeling Dominate modeling methodsmethods Object-oriented Analysis & Design (OOAD)
by Grady Booch
The Object Modeling Technique (OMT) by James Rumbaugh
The Object-oriented Software Engineering method (OOSE) by Ivar Jacobson
Booch (OOAD)Booch (OOAD)
Very complex The modeling language has too many types
of diagrams and diagram elements
Effective at low-level design Useful for documenting code
Good at OO Design, weak at OO Analysis
Rumbaugh (OMT)Rumbaugh (OMT)
A simpler modeling language Better at higher-level designs than Booch’s
Method.
Good at OO Analysis, weak at OO Design
OO Analysis vs. OO DesignOO Analysis vs. OO Design
Analysis refers to understanding the problem.
Design refers to coming up with the solution.
REQUIREMENTSand
ANALYSIS
DESIGN
IMPLEMENTATION
TESTING
Jacobson (OOSE)Jacobson (OOSE)
Major feature was "use classes" how a system interacts with users (other
systems or end users) Viewing things from the user’s perspective
Good at very high-level design
In summaryIn summary
Jacobson (OOSE) good at high-level design
Rumbaugh (OMT) good at the middle ground
Booch (OOAD) good at low-level design
ChronicsChronics of the UML of the UML1994 : Booch + Rumbaugh = Unified Method 0.8
1995 : + Jacobson = UML 0.8
Receiving a feedback from IBM, Microsoft, Oracle, HP and other companies
1996 : UML 0.9
1997 : UML 1.0
Object Management Group (OMG) joined UML project
1997 : UML 1.1
UML is running under the OMG Revision Task Force
Improving semantics and flexibility
2003 : UML 2.0
Standards bloat size of UML specification is dramatically increased too many diagrams that are redundant or
infrequently used problem in learning and adopting
The extremely poor writing of the UML standards themselves
written by a non-native English speakers an example of unintelligible geek-speak
UML and implementation language mismatch an intersection set between UML and
implementation language is very small
CriticismsCriticisms
Dysfunctional interchange format
The XMI (XML Metadata Interchange) standard is large and complex
The UML’s main purpose is not being an interchange format between modeling tools.
A lot of modelers who don't want to redraw their diagrams
Criticisms (cont.)Criticisms (cont.)
UML 2.0 diagramsUML 2.0 diagrams
ClassDiagram
ObjectDiagram
ComponentDiagram
CompositeStructureDiagram
PackageDiagram
Deployme ntDiagram
UseCase
Diagram
ActivityDiagram
StateMachineDiagram
SequenceDiagram
CommunicationDiagram
TimingDiagram
InteractionOverviewDiagram
Structure Diagrams Behavior Diagrams Interaction Diagrams
UML 2.0 ElementsUML 2.0 Elements
Behavioral Diagram Elements State Use Case Package …
Structural Diagram Elements Class Object Interface …
UML 2.0 ElementsUML 2.0 Elements
Links Composition Link Unidirectional Association Link Bidirectional Association Link Generalization Link
Multiplicity 0..1 No instances, or one instance 1 Exactly one instance 0..* Zero or more instances 1..* One or more instances (at least one)
Structural diagramsStructural diagramsClass diagramClass diagram
Class diagram gives a static view of the system EXAMPLE Modeling a family tree - this model is similar to a class diagramTo build a model we need to: Identify the main members of the family (CLASSES) Determine how they are related to each other (HIERARCHY) Identify the characteristics of each family member (ATTRIBUTES) Find relations among any members (RELATIONSHIPS BTW CLASSES) Decide the inheritance of personal traits and characters (INHERITANCE)
A class diagram consists of a group of classes and interfaces reflecting important entities of the business domain of the system being modeled, and the relationships between these classes and interfaces.
In a typical software development life cycle class diagrams are made by senior developers with the help of system architects.
Class Diagram-ExampleClass Diagram-Exampleclass name
relationships
StereotypesStereotypes It is an extension of the existing UML
elements; it allows you to define new elements modeled on the existing UML elements.
Graphically, a stereotype is rendered as a name enclosed by angle brackets (<< >>) and placed above the name of another element. In addition or alternatively it may be indicated by a specific icon.
In a class diagram stereotypes can be used to classify method behavior for example as <<constructor>>.
Constructor stereotype indicates that the operations following it are constructors.
Key Manager
<<constructor>>- New ()
<<misc>>+ GetInstance(): KeyManager
Behavior diagramsBehavior diagramsUse case diagramUse case diagram
Captures functional aspects of a system The Use case diagram is used to identify the
primary elements and processes that form the system. The primary elements are termed as "actors" and the processes are called "use cases".
The Use case diagram shows which "actors" interact with each "use case".
This kind of diagrams are made by business or functional domain experts
Use case diagramUse case diagram
Elements: Actors: An actor portrays
any entity (or entities) that performs certain roles in a given system
Interactions
Use case: a visual representation of a distinct business functionality in a system
State machine diagramState machine diagram
Class and use cases diagrams are static which means that they help in visualizing what the elements of the complete system would be, but do not say anything about the flows any object of the system can have when an event occurs.
State diagrams are used to help the developer better understand any complex/unusual functionalities or business flows of specialized areas of the system. In short, State diagrams depict the dynamic behavior of the entire system, or a sub-system, or even a single object in a system.
A state diagram can be defined not only for a system or subsystem, but also for an object in the system.
A state machine diagram specifies the sequence of events that an object goes through during its lifetime in response to events.
As an example, the following state machine diagram shows the states that a door goes through during its lifetime.
Activitiesstate
State machine diagramState machine diagram
Activity diagramActivity diagram
An Activity diagram is a dynamic diagram that shows the activity and the event that causes the object to be in the particular state.
A State diagram shows the different states an object is in during the lifecycle of its existence in the system, and the transitions in the states of the objects.
An Activity diagram talks more about these transitions and activities causing the changes in the object states.
Activity diagramActivity diagram
Activity to model : Attending a lecture at 8 am
Activity steps: Get dressed Make decision if there is
enough time to take bus Take bus, or take taxi
depending on decision Arrive at school and attend
lecture
Initial state
Final state
In time for bus Not in time for bus
Take bus to school Take taxi to school
Attend lecture
Get dressed
Sequence diagramSequence diagram Shows object interactionShows object interaction over time
One of the most widely used dynamic diagrams in UML
A Sequence diagram depicts the sequence of actions that occur in a system. The invocation of methods in each object, and the order in which the invocation occurs is captured in a Sequence diagram.
Sequence diagramSequence diagram Two-dimensional:
Vertical axis - life of the object that it representsHorizontal axis - the sequence of the creation or invocation of these objects.
:CommsController :WeatherStation :WeatherData
request (report)
acknowledge()request ()
summarize()
send(report)reply (report)
acknowledge()Life line
Activation
Object
Actor
Structural components: Telephone Cellular radio Display Microphone Speaker Button Dialer
Communication diagramCommunication diagram
:Speaker
:Button :Dialer :Cellular radio
:Send:Button:Display
1*:Digit(code)
1.1:DisplayDigit(code)
2:Send()
2.1.1 :In Use()
2.1:Connect(pno)
1.2:EmitTone(code)
Diagram shows how several objects collaborate to get job done. Models object interactions and structural dependencies
Use case:
user makes a call
Example: Software system that controls simple cell phone
Structure diagrams for Structure diagrams for implementationimplementation
Component diagramComponent diagram
Component diagrams represent the implementation perspective of a system. Hence, components in a Component diagram reflect grouping of the different design elements of a system, for example, classes of the system.
Deployment diagramDeployment diagram The deployment diagram captures the configuration of
the runtime elements of the application and represents interactions between software and hardware.
The deployment diagram elements provide the necessary environment for the components to execute in.
The basic deployment diagram element is the node. The node represents the environment in which a component or a set of components execute.
Deployment diagram should start from the time when static design is being formalized using, say, class diagrams.
This deployment diagram evolves and is revised until the system is built.
Deployment diagramDeployment diagram
Example: University information system
nodes
Software development Software development phases phases and UMLand UML
Software lifecycle: Requirements definition
Use case diagrams Activity diagrams Sequence diagrams Communication diagram
System and software design and implementation Component diagrams Class diagram State diagram
Deployment Deployment diagram
Frameworks Frameworks and Design and Design
PatternsPatterns
John Hautzinger, Sae Rom Hong
Patterns and FrameworksPatterns and Frameworks
Classes Mechanism for encapsulation Provides a single service Rarely a complete solution
Application Frameworks and Design Patterns became popular solutions
Application FrameworksApplication Frameworks
Set of classes that cooperate with each other Together embody reusable design for a general
category of problems
Framework dictates the overall function and behavior of the application. Describes how responsibilities are partitioned
between various components and how they interact.
Application Frameworks Application Frameworks (Cont.)(Cont.) Application Frameworks became popular
with the rise of GUIs These tended to promote standard structures
Commercial Application Frameworks MacApp
First commercial application framework Microsoft Foundation Classes (MFC) Oracle Application Development Frameworks
Oracle ADF Aids in producing Java-oriented systems
Swing
Popular FrameworksPopular Frameworks
Swing Developed to provide a more sophisticated
set of GUI components than Abstract Window Toolkit (AWT)
Highly partitioned to allow extensibility Users can provide their own custom
implementations of these components to override the default implementations
Highly Customizable, Configurable, and Lightweight
Popular FrameworksPopular Frameworks
Oracle Application Development Framework Java framework for developing enterprise
applications Supports rapid application development
using design patterns Supports many software frameworks
A Framework as an Upside-A Framework as an Upside-down Librarydown Library In a traditional application-specific code
defines overall flow of execution, occasionally invoking library-supplied code Frameworks reverse this relation
Flow of control is dictated by the Framework and the creator of a new application merely changes some of the methods invoked by the framework
Inheritance is often used for achieving this Alternatively application-specific components
that obey a specified interface are plugged in
Application Framework Application Framework ExamplesExamples GUI application frameworks simplify the
construction of graphical user interfaces A GUI application framework implements the
behavior expected from a graphical user interface Hold windows, buttons, menus, etc..
A new application is built by specifying and arranging necessary elements and modifying certain methods
Another AF ExampleAnother AF Example
Simulation frameworks simplify the creation of simulation style applications
Simulation frameworks provide general-purpose classes for managing the types of objects in the simulation
The heart of the simulation framework is a procedure that cycles through the list of objects introduced and asks each to update itself
The framework knows nothing of the particular application
Toolkits and FrameworksToolkits and FrameworksMain body of an application
Reuse the main body of anApplication and write the code it calls
Toolkit Framework
Calls a procedure or a method
Defines the architectureor the application
Toolkits: Collection of related and reusable classese.g. C++ I/O stream library
Framework: A set of cooperating classes thatmake up a reusable design for a specificclass of applications e.g. drawing, compilers,CAD/CAM etc.
Disadvantages of Disadvantages of FrameworksFrameworks May add to "code bloat"
Due to both competing and complimentary frameworks sometimes being needed
Some 'one size fits all' frameworks' add much unused code
Can be argued that frameworks may add to development time Developers must take time to learn the
framework
Questions about Questions about FrameworksFrameworks When using frameworks, what defines the
architecture of the application? In a traditional application the architecture of is defined
by the specific functional problem that the application needs to solve
Using a framework, in addition to the problem needing to be solved, the architecture is defined by the framework in use
What is more difficult to design: Application, toolkit, or frameworks? Frameworks are the most difficult to design, they
permeate the entire application and dictate its architecture.
Questions about Questions about FrameworksFrameworks How do changes in framework affect an
application? Since the framework permeates the application on
almost every level, major changes to the framework may change the way the application functions. This may result in changes that need to be made in the code and/or logic of the application
How do design patterns differ from frameworks? A design pattern is not a finished design that can be
transformed into code. It is a description or template for how to solve a problem that can be used in many different situations. Frameworks can be directly implemented into an application whereas design patterns
Design Design PatternsPatterns
Design Design Goals Goals Reusability, Flexibility, and Maintainability
Reuse flexible designs Keep code at a general level Minimize dependency on other classes
Robustness Reuse reliable designs Reuse robust parts
Sufficiency and Correctness Modularize design Reuse trusted parts
What are Design Patterns?What are Design Patterns?
Design patterns are an attempt to collect and catalog the smallest recurring architectures in object oriented software systems.
A design pattern expresses an idea rather than a fixed class combination
Design patterns are more abstract than a framework
It conveys an idea, however, not a completely specific design.
What are Design Patterns?What are Design Patterns?
Housing Preferences to a realtor
Ranch StyleSpanish Colonial
Style
Victorian House Style
BungalowStyle
Example how patterns express idea:
Design Patterns VS AlgorithmDesign Patterns VS Algorithm
Efficiency is used to describe properties of an algorithm relating to how much of various types of resources it consumes Speed Memory
Design Patterns is more related to relationships in OOP
Taxonomy of Design PatternsTaxonomy of Design Patterns
Purpose: depending upon whether it has to do with
Creational Design Creational Design PatternsPatterns Abstracts the instantiation process:
Encapsulates knowledge about which concrete classes to use
Hides how the instances of these classes are created and put together
Gives a lot of flexibility in what gets created, who creates it, how it gets created, and when it gets created
A class creational pattern uses inheritance to vary the class that is instantiated
An object creational pattern delegates instantiation to another object
Creational Design PatternsCreational Design Patterns
Design Pattern Name
Design Purpose Satisfied by this
Pattern
Summary of the Design Pattern
Factory MethodCreate objects at
runtime with flexibility Created desired
objects
Abstract FactoryCreate coordinated families of objects
Capture each family in a class
Prototype
Create an aggregate object in which
selected parts are essentially copies
Create the objects of the type cloning a
prototype
SingletonEnsure that a class has
exactly one instantiation
Make the constructor private and obtain the
unique object
Builder
Structural Design PatternsStructural Design Patterns Structural design patterns are concerned with
how classes and objects are composed to from larger structures
A class structural pattern uses inheritance to compose interfaces or implementation; compositions are fixed at design time
An object structural pattern describes ways to compose objects to realize new functionality; the added flexibility of object composition comes from the ability to change the composition at run-time
Structural Design PatternsStructural Design Patterns
Design Pattern Name
Design Purpose Satisfied by this
Pattern
Summary of the Design Pattern
Composite
Façade
Proxy
Flyweight
Adapter
Bridge
Decorator
Behavioral Design Behavioral Design PatternsPatterns Behavioral design patterns are concerned with
algorithms and the assignment of responsibilities between objects
Behavioral class patterns use inheritance to distribute behavior between classes
Behavioral object patterns use object composition rather than inheritance; some describe how a group of peer objects cooperate to perform a tasks no single object can carry out by itself; others are concerned with encapsulating behavior in an object and delegating request to it
Behavioral Design Behavioral Design PatternsPatterns
Design Pattern Name
Design Purpose Satisfied by this
Pattern
Summary of the Design Pattern
Chain of Responsibility
Command
Interpreter / Iterator
Mediator
Observer
State
Strategy
Visitor
Memento
The Elements of a Design The Elements of a Design PatternPattern
Thank you Thank you