Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 14: Object-Oriented Design

Similar presentations


Presentation on theme: "Chapter 14: Object-Oriented Design"— Presentation transcript:

1 Chapter 14: Object-Oriented Design
based on abstractions of real-world or system entities objects manage a private state communication by message passing advantages obvious map to real-world easier to debug due to reduced system coupling easier reuse easier maintenance (objects are stand-alone entities) Functional design based on interacting functional components of a solution functions share a global state communication via shared variables advantages functional data flow may be more intuitive more obvious control model

2 Object-oriented development
Three related but distinct OO stages analysis (OOA) : develop an object model of the application domain design (OOD): develop an object-oriented system model to implement requirements programming (OOP) : realize an OOD using an OO language such as C++ Commonalities: identifying objects, attributes and services organizing objects into an aggregation hierarchy constructing object-use descriptions to show how services are used specifying object interfaces

3 Passive and active objects
Passive objects all state changes effected through operations defined in the object interface e.g. aStack.Push(item) Active objects can change their own state e.g. an object might have a (private) timer to update its state every 100 ms (similar to JavaScript setTimeout)

4 14.2 Object identification
The most difficult part of object oriented design No 'magic formula' for object identification Relies on skill, experience, and domain knowledge Iterative--you are unlikely to get it right first time How is this like anything else you do well? Approaches grammatical based on a description of the system: nouns are objects, adjectives are attributes, verbs are operations identify tangible things in the application domain behavioral, identifying objects based on what participates in what behavior scenario analysis

5 An office information system
The Office Information Retrieval System (OIRS) is an automatic file clerk which can file documents under some name in one or more indexes, retrieve documents, display and maintain document indexes, archive documents and destroy documents. The system is activated by a request from the user and always returns a message to the user indicating the success or failure of the request.

6 An office information system
The Office Information Retrieval System (OIRS) is an automatic file clerk which can file documents under some name in one or more indexes, retrieve documents, display and maintain document indexes, archive documents and destroy documents. The system is activated by a request from the user and always returns a message to the user indicating the success or failure of the request. File Retr ie v e Archiv Destro y Document Name Displa Delete entr Add entr Inde x Put message User Retrie al system Name Name Diff names for the same object obvious knowledge left out (index has a name, documents have owners GO to behavoiral approach Go to use case diagrams User command Get command

7 Weather mapping system
A weather mapping system is required to generate weather maps on a regular basis using data collected from remote, unattended weather stations and other data sources such as weather observers, balloons and satellites. Weather stations transmit their data to the area computer in response to a request from that machine. The area computer system validates the collected data and integrates it with the data from different sources. The integrated data is archived and, using data from this archive and a digitised map database a set of local weather maps is created. Maps may be printed for distribution on a special-purpose map printer or may be displayed in a number of different formats. Will look at this two ways 1. non-layered 2. layered

8 Top-level architectures Non-layered Layered
«subsystem» Data collection Data processing Data archiving Data display Data collection layer where objects are concerned with acquiring data from remote sources Data processing layer where objects are concerned with checking and integ rating the collected data Data archiving layer where objects are concerned with storing the data for future processing Data display layer where objects are concerned with preparing and presenting the data in a human- readable form

9 Subsystems derived from layered view

10 Comment on notation The design is organized into logically related groups of objects In the UML, these are encapsulated using packages This is a logical model The actual organization of objects in the system may be different Next step: decompose weather station subsystem

11 Weather station objects
Use domain knowledge to identify more objects and operations weather stations should have a unique identifier weather stations are remotely situated so instrument failures have to be reported automatically, therefore attributes and operations for self-checking are required Active or passive objects? in this case, objects are passive and collect data on request rather than autonomously this introduces flexibility at the expense of controller processing time What are the objects inside this? Identifier W eather data Instr ument status Initializ e T r ansmit data ansmit status Self test Shut do wn eather station

12 Hardware control objects
est W ind v ane Direction Reset Rain gaug e Rainf all Calibr ate Bar ometer Pressure Height Air thermometer emper ature Gr ound Anemometer thermometer T emper ature Wind speed T est T est Calibr ate Hardware objects correspond directly to sensors or actuators connected to the system They conceal the details of the hardware control e.g. buffer address, masking bit pattern etc. Hardware changes can often be introduced by hardware object re-implementation

13 Weather data objects Air temper ature data Ground temper
Wind speed data Wind direction data Pressure Rainf all Mak e readings Process data W eather data Readings Maxim um Minim A v er age Read T emperature data Max. gust ind speed data W ind direction Rainfall data Readings Cum ulativ e Read Read

14 Weather station subsystems (layered)

15 Object interface design
Specify the detail of the object interfaces so that objects can be developed in parallel This means defining attribute types the signatures and semantics of object operations Use a programming language to achieve precision Avoid representation information i n t e rf a c e We h r S ti o { p u b li v d We at he ta ( ) ; s () (I st me i) w m en t i ep or tW In nt al e ( I g D } //

16 Design evolution How would you add pollution monitoring facilities to the weather stations? (to sample the air and compute the amounts of different pollutants) (pollution readings are transmitted with weather data) Changes required: add an object class called AirQuality as part of WeatherStation. add an operation reportAirQuality to WeatherStation. Modify the control software to collect pollution readings. add objects representing pollution monitoring instruments. W eatherStation Air quality P ollution monitoring instruments identifier NOData smok eData repor tW eather () NOmeter SmokeMeter benz eneData repor tAirQuality () calibrate (instruments) collect () test () BenzeneMeter summarise () star tup (instruments) shutdown (instruments)

17 Weather station subsystems (layered)
Inter face Data collection CommsController W eatherData Instrument W eatherStation Status «subsystem» Instruments Air thermometer RainGauge Anemometer Ground Barometer W indV ane thermometer NO meter Smoke meter Benzine meter

18 Other pieces mentioned in text
State machines show responses to requests for services Sequence diagrams show interactions among objects


Download ppt "Chapter 14: Object-Oriented Design"

Similar presentations


Ads by Google