950 likes | 1.21k Views
OO METHODOLOGY. NOTES. Agenda. Fundamental Concepts in Object-Oriented Methodologies Objects, Classes, Structures among Classes Behavior of Objects, State, State charts UML Some Topics in OO Methodologies Constraints and OCL Proving Constraints. What is Object-Oriented Methodology ?.
E N D
OO METHODOLOGY NOTES
Agenda • Fundamental Concepts in Object-Oriented Methodologies • Objects, Classes, Structures among Classes • Behavior of Objects, State, State charts • UML • Some Topics in OO Methodologies • Constraints and OCL • Proving Constraints
What is Object-Oriented Methodology ? • Software development method based on Object-Oriented Paradigm • Our world is a collection of collaborating entities called “objects” • Software has to be organized according to the structure of our world • It increases understandability. • It makes evolution of software easier.
Object-Oriented Paradigm • Our Word is a collection of collaborating entities President Sales dept. Factory Factory workers Engineers Scientists
Object-Oriented Paradigm • Organize software according to the structure of the world Management Information Object Factory Management Object Sales Dept. Object Worker Object Laboratory Object Design Object
Requirement analysis, Specification, Design Problem P⇒P' Platform M⇒M' Real World W⇒W' Design D⇒D' Programming, Test Program S⇒S‘
Software Evolution The most difficult and costly part in software lifecycle • Missing design information • Legacy code problem • Difficulty of understanding and comprehending the entire system from the beginning of its development. • Complex systems can only be build only through evolution. Evolutionary prototyping • New applications require evolution • Open system • Need to adapt to unknown environments
Computationally, Objects are… • Elements of the world to be described • Autonomous behavioral elements • Object=Attributes+Operations+Behavior • Attributes:Local data of object • Operations:For changing/referencing the attributes • Behavior:Upon receiving stimulus(event), the object (1) perform operations, (2) changes its states and (3) sends out events to other objects. • Usually, modeled as statecharts or event-driven program • Object is encapsulated. • No internal state and attribute values can be seen from outside the object.
Communication via events Attribute: position,color,... Operation: draw, paint, move,.... Behavior: e/move, e’
Description of the World • How do we describe the world? • Class concept + Relations among classes • Class as a set of “similar objects” in the world • Abstraction :{professor Shinoda, professor Tan, …} class “professor” • Instantiation : “professor” professor Shinoda • Class concepts provides economy and reuse of thought and description.
Objects and Classes Japan object: China abstraction Germany Indonesia instantiation class: Country Tan Gill lives-in class: People
Relationships Among Classes • Class Hierarchy, Inheritance, “is a” • Generalization/Specialization • Mammal < Monkey < Human • Composition, Aggregation, “has a” • Automobile=Body+Wheels+Steering+Engine • Association, a general relation between classes People―(lives-in)―Country • Dependency, Realization,...
Two Major Issues in Object-Oriented Methodology • Object-Oriented Analysis/Design • BOOCH, OMT, UML, Catalysis methods • Constraints, Formal Approach, Analysis Patterns,Unified Process, … • Object-Oriented Programming • OO languages: Smalltalk, C++, Java • Design Patterns, Frameworks , Class Libraries …
Typical Object-Oriented Development Process Architecture design Choice of impl. strategy Object design Analyzing requirement Object model Reqrmnts Design Analysis Coding Dynamic model Coding in OO language ・・・ Analysis models
Multiple Analysis Models • Description of a single model from multiple views which are almost independent • Eight Models + One Language in UML division company section Object Model for classes in the world and their relationship e1/e2, u=f(v) s2 s1 employee main x sub1 z Dynamic Model for behavior description of each object sub3 y sub2 Functional Model for data flow in the world
UML • Notations to describe every aspects of software development • From business systems to industrial embedded systems • Unified notations in Booch method, OMT method(Rumbaugh), OOSE method (Jacobson) • Becoming a standard language of software engineer
UML- Eight Diagrams and One Language • Use Case Diagram • Class Diagram/Object Diagram • State Diagram • Sequence Diagram • Collaboration Diagram • Activity Diagram • Component Diagram • Deployment Diagram • OCL(Object Constraint Language)
Use Case Diagram • Use Cases describe a rough sketch of functions or “usage” of the system looked from the actors outside the system. • System functions are described by a set of use cases.
Use Case Diagram Use cases : specifies functions of system Actor : human, machine,… interacting with the system Sign an insurance policy Process sales statistics Process customer statistics Customer Insurance Salesperson Insurance System
Description of Use Case • By sentences or activity diagrams • Purpose of use case • How the use case is initiated • Message flow between actors and use case • Alternative flow • conditional/exceptional flow • do not go into too much details • Utilizing of other use cases : use case call • How the use case is terminated
Use cases are described by activity diagrams if they are well-defined. Insert coins Enough coins inserted? Show that drink can be chosen Show that drink is not available Choose drink drink not available Drink customer drink available Deliver drink
In OO development, use cases are used to find objects. Functions represented by the use cases are realized as collaborations among the objects. <<realizes>> collaboration use case U <<implements>> use case description 1.the actor depresses an button 2.action 1 is executed 3.a message is sent to the actor 4. … class Drink op1 op2 class Disp op1 op2 op3 class Button op1 op2 op3 discover classes
Class Diagrams • Classes in the system + Relations • Relations among classes • Inheritance • Aggregation • Association • Dependency • Realization
Class and Object Employee Employee Employee name:String name:’Smith’ name:’Sharp’ pos:String pos:’eng’ pos:’chief eng’ promote promote promote Class Employee Objects instantiated from the class Employee
Link and Association • Link : Relation among objects instantiated from classes • Channel for event transmission • Access path for data access/navigation Person Company workat Joe Smith Simplex Co.
Association : Relation between classes • Abstraction of links between objects Person Company workat Joe Smith∈Person Simplex Co.∈Company
Link and Classes R ・ If O1―O2 for some O1∈C1,O2∈C2 then C1―C2 ・ R⊆C1×C2 O represents objects instantiated from the class C R
Direct Products of Sets and Relations • Direct Product C1×C2={(O1,O2)|O1∈C1,O2∈C2} • Relation R between C1 and C2 : R⊆ C1×C2 • Parent relation P⊆Human×Human P={(x,y) | y is a parent of x, x,y are in Human} • Devisor relation D⊆N×N, N:the set of natural numbers D={(m,n) | n=km for some k in N} • When (O1,O2)∈R, we write O1ーO2 R
Association and Multiplicity 0..* 2..* Line name Point name Intersect Line L1 Point P1 Line L2 Point P1 L2 Line L3 P1 P2 L3 Line L4 L1 L4 L5 Line L5
Inheritance Equipment name manufacturer weight cost Attributes and operations are inherited from super classes Heat exchanger Pump Tank suction pressure discharge pressure flow rate surface area tube diameter …. volume pressure Diaphragm pump name=P101 manufacture=Simplex … suct pressure=1.1 atm … diaph material=Teflon Diaphragm pump Plunger pump Floating roof tank diameter height diaphragm material
A B Inheritance • A method for classifying classes according to their generality • Inheritance is not an association B inherits attributes and operations from A Attr*(B)=Attr*(A)∪Attr(B) Op*(B)=Op*(A)∪Op(B) where, Attr*(C):attributes effective at C Attr(C):attributes defined in C Op, Op*: similarly super class subclass
Aggregation Computer 1..* System box Monitor Mouse Keyboard 1..* 0..1 Fan CPU RAM Chassis
A B C • Aggregation is a special case of association • Object of the class A is together with objects of the Class B and C as OA(OB,OC). • State space of the object in the class A =V(Attr*(A))×V(Attr*(B))×V(Attr*(C)) • Attr*(X): attributes effective at class X • V({a,b,...,c})=V(a)×V(b)×…×V(c) • V(a)= set of values which the attribute a can take.
OB Attr B 2.Operations of the object OA of the class A is delegated to its parts OB,OC OA Attr A OC Attr C Reacting to events from outside, OA send events to OB and OC asking to perform the associated tasks. Their results are sent back to OA.
Person document character paragraph copy copy copy An Example of Delegation copy copy having * * *
Aggregation and Inheritance • Aggregation is inherited. A D B C * E Object of D has parts which are objects of B,C and E. OD(OB,OC,OE1,OE2,...)
Wiring Lamp Switch Base Socket Twist mount Starter Cover Ballast Fluores- ent Lamp Incandes- cent Lamp
program block Recursive Aggregation program::={block} block::=simple statement |compound statement compound statement::={block} {A}≡ε|A|AA|AAA|… * * compound sentence simple statement
Dependency • Utilize class A in class B • B has A as a parameter • B accesses data in A • B uses operations A • Change of A affects B class A class B
Realization • Class B is a realization of A • B is more concrete • A is more abstract • R: mapping B A R class A class B
Interface and Realization • Interface is a special class with abstract operation. It is used with classes which realize/implement them. <<interface>> ChoiceBlock setDefault(choice:Choice) getChoice():Choice PopupMenu setDefault(choice:String) getChoice():String 1..* choice 1..* choice realization <<interface>> Choice String specifier implementation
Dynamical Views • State Diagram/Statechart • Specify dynamics of individual object • Sequence Diagram • Event sequence observed in collaborating objects • Collaboration Diagram • Different notation of sequence diagram • Activity Diagram • Action + Control structure • Flowchart
State Diagram • Description of individual objects • Fundamental concepts • event, state, scenario, event trace, state transition, state transition diagram, operation, action • Advanced concepts • nested transition diagram, generalized state, concurrency, event dispatching, synchronization of concurrency
Event and Event Trace • Event • Stimulus which an object transmit to other objects • Object reacts to events and perform associated tasks • Event has no duration time. • Event may have attributes, which represents its contents
Event Trace • Sequence of events • Scenario • Sequence of events observe when the system performs some function • Event Trace Diagram/Sequence Diagam
An Event Sequence in a Telephone System object event Caller Phone line Callee caller-lifts-receiver dial-tone-begins dial(5) dial(1) callee-hangs-up connection-broken connectin-broken caller-hangs-up
s = ( attr1:12, attr2:5, L1:O1, L2:O3 ) L1 attr1=12,attr2=5 L2 O3∈C3 O1∈C1 O2∈C2 s∈state(C2)=V(attr1)×V(attr2)×C1×C3 State • Status of object at a certain time • Represented by attribute values and links
Behavior of Object and Its State • Object become active reacting by receiving event. • On receiving events, the object performs operation and change its state. It performs the same operation at the same state. • It remains in the state until it receives new events.
object event Caller Phone line Callee caller-lifts-receiver state dial-tone-begins dial(5) dial(1) callee-hangs-up connection-broken connectin-broken caller-hangs-up
e1e2e3.... S≡{e1e2e3.... | S0 → S } Characterization of State • Sequence of events leading to the state from the initial state e3 e2 e1 Sinit S