280 likes | 385 Views
Object-Oriented Software Engineering. CS288. Lecture 1 - Object-Orientation & UML. Contents Overview Classifiers Dynamic Behaviour Static Modelling Summing Up. Unified Modelling Language. First introduced in 1999 (about) Still evolving, and extremely popular language
E N D
Lecture 1 - Object-Orientation & UML Contents • Overview • Classifiers • Dynamic Behaviour • Static Modelling • Summing Up
Unified Modelling Language • First introduced in 1999 (about) • Still evolving, and extremely popular language • Current version 2.0 ratified August 2003 • We use UML 1.4, which is the current standard widely adopted in industry
Think before you code. UML allows us to build a conceptual model that we can examine and understand before we write a single line of code. • Java allows us to closely tie the concepts from the UML model directly to the implementation. • Easier to verify • Easier to modify • Easier to reuse Unified Modelling Language
Unified Modelling Language • Visual modelling language • Specify • Visualise • Construct • Document • UML can be used to capture information about: • Static structure • Dynamic behaviour • Environmental aspects • Organisational aspects
Deployment View CreditCardCharges CustomerInterface ManagerInterface ServiceInterface ItemSeller ItemDB SalesServer 1 1 * * SalesTerminal Client Overview
Static View height: Real age: Real Person Male_Person Female_Person Overview
Overview publicclass Person { public double height; public double age; } class Male_Person extends Person { // Now add stuff here to change // attributes and behaviour } class Female_Person extends Person { // Now add stuff here to change // attributes and behaviour }
Behavioural View: Single Object timed out buy lock Available Locked Sold unlock Overview
Overview Dynamic behaviour: communication patterns customer vendor credit service request item show availability select item demand payment insert card charge card
Classifiers Name <<subsystem>>
Withdraw Cash <<include>> Validate PIN <<include>> Query Account Add Cash <<include>> ATM Customer Operator Order Statement Startup Shutdown Dynamic Behaviour: Use Cases
ATM Card ATM Control Customer Interface Bank Server Card Inserted Get Pin ATM Customer PIN Prompt PIN Input Card Request Card Data PIN Entered Validate PIN Dynamic Behaviour: Sequence Chart
Dynamic Behaviour: State • A condition or situation during the life of an object during which it satisfies some condition, performs some action, or waits for some event. • The Unified Modelling Reference Manual • I.E. State captures all the relevant information about an object at one specific moment with respect to the purpose of the object.
Representation of a State Activate Phone entry/ register on network exit / disconnect from network
Closed Down startup Idle closedown Events trigger Transitions Top-level Statechart for ATM Control
guard condition actions event name StateA StateB e1 [cond] / action1;action2 Full Label for a Transition
Closed Down startup closedown card inserted / get pin Idle Entry / display Welcome Terminating Transaction validation received [invalid card] / confiscate Processing Transaction withdrawal selected [valid card] / display wait More ATM Control Processing Customer Input
Phone Composite State Example Power On Off On Power Off
Phone Composite State Example On Power On Idle incoming-call Off unlock end Power Off Active
Phone Composite State Example On Idle incoming-call Power On unlock end Off Active Dialling 0-9 Power Off connect-fail Ringing connect-key Connecting Talking connect-key call-accepted
Tuner class name Channel Frequency attributes Get_Frequency Set_Frequency operations Static Modelling: Class
A/V Tuner FM Tuner Static Modelling: Inheritance Hierarchy Tuner
Static Modelling: Association Tuner 1 Surf List Binary relation between classes 1 Can be implemented in different ways 1 Surf List to 1 Tuner
Surf List Surf List Size Add Surf Channel Delete Surf Channel Set Surf Channel Source ID 0..* Preset Number Preset Name Edit Preset Number Edit Preset Name Static Modelling: Aggregation • Specifies that an aggregate classis made up from components. • Here: A Surf List has 0 or more Source ID
1 1..* University School 1 1..* Department Nested Aggregates 1..* 1 1..* 0..* Lecturer Students Static Modelling: Aggregation
is tuned to Source ID 0..* Front End External Source 1 Surf List 1..* 1 Tuner Static Modelling: Putting it all together A/V Source
Summing Up • UML is a visual modelling language that covers a range of aspects of systems analysis and design • We have seen examples of modelling static structure and dynamic behaviour • Environmental and Organisational aspects can be covered too ______________ • Use it!