320 likes | 462 Views
A Brief Overview of the Unified Modeling Language. Bran Selic ObjecTime Limited bran@objectime.com. Rev.2. Overview. Introduction The Object Paradigm Modeling with the UML Summary. What is the UML?. 1996. OMT (Rumbaugh et al.). UML 0.9. UML 1.1. UML 1.4. Nov. 1997. Mar. 1999.
E N D
A Brief Overview of the Unified Modeling Language Bran SelicObjecTime Limited bran@objectime.com Rev.2
Overview • Introduction • The Object Paradigm • Modeling with the UML • Summary
What is the UML? 1996 OMT (Rumbaugh et al.) UML 0.9 UML 1.1 UML 1.4 Nov. 1997 Mar. 1999 OOSE (Jacobson et al.) Booch • General-purpose OO modeling language • convergence of a number of popular OO methods Catalysis ROOM etc.
Inside the Standard • Semi-formal semantic meta model • defines the basic modeling concepts • object, class, association, etc. • includes formal well-formedness rules expressed as constraints in the Object Constraint Language (OCL) • Graphical notation for modeling concepts • 8 different diagram types • Two predefined domain extensions
Introduction • The Object Paradigm • Modeling with the UML • Summary
A Brief History of Objects • 1967: Simula programming language • 1970’s: Smalltalk programming language • 1980’s: Theoretical foundations, C++, Objective-C, etc. • 1990’s: Object-oriented analysis and design methodologies (Booch, OMT, ROOM, etc.), Java • 1997: The Unified Modeling Language (UML) standardized by the Object Management Group (OMG)
The Object Paradigm • A synergistic combination of various proven techniques including: • encapsulation • inheritance • polymorphism/genericity • Salient characteristic: a software system is rendered as a structure of collaborating parts • the object paradigm is inherently structural
Structure • The individual parts of a system and their run-time topological relationships • Fundamental structural relationship types: • Containment (strong and weak) composition (strong) aggregation (weak) • Layering • Communication (links)
Objects void:offHook (); {busy = true; reqDialtone(); … }; • Entities that model some physical or conceptual entity • a unique identity (dedicated memory) • the conceptual becomes physical! • a public interface • a hidden (encapsulated) implementation methods public attributes Telephone1: +busy : boolean public operations +offHook() +onHook () +ring()
Conceptual Objects Telephone1 Telephone2 Telephone Call Telephone Call Object • Not all objects necessarily require a physical underpinning • For example, the “telephone call” object: abortCall () addParty (t:Telephone) reportDuration ()
Classes and Instances Telephone phone1:Telephone phone2:Telephone busy : boolean busy = true busy = false offHook() onHook () ring() offHook() onHook () ring() offHook() onHook () ring() • Design-time specifications for one or more distinct objects with a common form (structure and behavior) instance (run time) class (design time)
Object Behavior void:offHook (); {busy = true; obj.reqDialtone(); … }; • Simple basic reactive server model: InitializeObject Handling depends on specific request type and object state Wait forRequest HandleRequest Invokes operations on other objects TerminateObject
Programming Model 3.sendTone() 2.call() PhoneIF: CallProc: ToneGen: 1.offHook() 4.dialtone() • Combining objects into object structures
Object “Engines” InitializeObject Wait forRequest InitializeObject HandleRequest Wait forRequest HandleRequest TerminateObject TerminateObject • Passive objects: depend on external motive power (e.g., “main” program thread) • Active objects: self-powered (own thread of execution)
Inheritance and Polymorphism TelephoneClass RotaryDialTelephoneClass busy : boolean busy : boolean TouchToneTelephoneClass offHook() onHook () dialDigit() offHook() onHook () dialDigit() Polymorphism: an operation implemented differently in different classes busy : boolean offHook() onHook () dialDigit() playTone() • Generalization and re-use mechanisms Generalization (inheritance) association
Introduction • The Object Paradigm • Modeling with the UML • Summary
Why Build Models? • To understand the problem better • To communicate with stakeholders • To find errors or omissions • To plan out the design • To generate code
UML Model Views • Requirements (use case diagrams) • Static structure (class diagrams) • kinds of objects and their relationships • Dynamic behavior (state machines) • possible life histories of an object • Interactive behavior (activity, sequence, and collaboration diagrams) • flow of control among objects to achieve system-level behavior • Physical implementation structures (component and deployment diagrams) • software modules and deployment on physical nodes
Class Diagram - Static Structure FinancialInstitution client creditor 0..* 0..* owner 0..* Mortgage principal rate term Bank TrustCompany 0..* 1 • Shows the entities in a system and their general relationships association class Person generalization association residence 0..* {ordered} House
Object Instance Diagram RoyalBank : Bank JoeYu:Person first : Mortgage second : Mortgage cottage : House home : House • Shows object instances in a particular case link
State Machine Diagram InitializeObject Wait forEvent created start/^master.ready() HandleEvent ready stop/ poll/^master.ack() TerminateObject • Each state corresponds to a selective receive action state machine initial state state trigger action expression final state transition
State Machine Behavior poll/defer ready start created created start/^master.ready() ready ready stop/ start/ • Event handling details depend on state start/^master.ready()
Active Objects in the UML ActiveObject: • Concurrent incoming events are queued and handled one-at-a-time regardless of priority • run-to-completion (RTC) execution model
RTC and Concurrency ActiveObject: • Eliminates need to write complex and error-prone synchronization code • if all passive objects encapsulated by an active object, only a single thread can pass through each passive object passive encapsulated objects (protected attributes) The event handler is an implicit critical region
RTC Semantics • RTC step semantics must not be confused with uninterruptibility or unpre-emptabilty • interrupts do not have to be blocked • an active object can be pre-empted by another active object responding to a higher-priority event • priority inversion only occurs when an active object blocks itself (i.e. it cannot block any other active object) • The effectiveness of this is supported by the following empirical results • most event handling is trivial • in computer terms, events occur infrequently
State-Based Actions print/printContents(); Operational start/ stop/ • Entry action: executed whenever a state is (re-)entered • Exit action: executed whenever a state is departed • Internal transition: a self transition executed without leaving and re-entering a state entry/^m.entered(); exit/^m.departed() poll/^m.ack()
Hierarchical States and Transitions off/ OffLine on/ OnLine Ready done/ req/handle() Busy • Allows step-wise refinement and viewing of complex behavior group transition default transition composite state
Signals «signal»Alarm «signal»FireAlarm «signal»MedicalEmergency severity : integer severity : integer address : Address severity : integer type : EmergencyType • Used for asynchronous communication • specified by a special type of class • can be organized into class hierarchies
Sequence Diagrams Caller Operator Callee call number call ack ack transfer talk time • Assertions of legal interactions between objects (e.g., operator-assisted call) sequence diagram
Collaboration Diagram CallProc 2.call() 3.sendTone() PhoneIF ToneGen 4.dialtone() 1.offHook() • Show generic structure and behavior classifier role P2:TTSet P1:BusSet P2:TTSet P1:BusSet
Introduction • The Object Paradigm • Modeling with the UML • Summary
Summary: the UML • An industry standard for analysis and design of object-oriented systems • based on extensive experience and best practices • gaining rapid acceptance (training, tools, books) • Comprises: • set of modeling concepts • graphical notation • Leaf concepts organized into 8 diagram types • class, state machine, collaboration, use case, sequence, activity, component, deployment • The UML can be used in many different domains to capture domain-specific concepts and ideas