COS 50 3 OOSD Object Oriented Analysis Week
COS 50 -3 OOSD Object Oriented Analysis (Week 3) 1/11/2022 Dayou Li / Marc Conrad 1
OBJECT • An object is an entity which consists of a number of operations and a state which remembers the effect of the operations. • State is regarded as information which is saved in a set of variables. • Operations read and/or affect the information. • The only part that can be seen by an outsider is the operations. For this reason, operations are also known as behaviours. • Information is hidden to the outsider. 1/11/2022 Dayou Li / Marc Conrad 2
OBJECT (Cont’d) Example: a person as an object Information: Name, Age, Address, Friends, . . . 1/11/2022 Behaviour: jump bend legs stretch legs lift arms, . . . walk talk Dayou Li / Marc Conrad 3
CLASS and INSTANCE • Class is a template or abstract description of the same type of objects. It defines the common features of the objects, that is the operations and information structure. • Instance is an object created from a class. • An instance’s behaviour and information structure is defined in the class. • Its current state (values of instance variables) is determined by operations performed on it. 1/11/2022 Dayou Li / Marc Conrad 4
INHERITANCE • Inheritance takes place when a subclass of a superclass is created. • A subclass inherits behaviours and information structure (class members) from its parent class. • It can refine the operations and can even add some extra operations and information. • Note: not all operations and information a subclass can inherit. Pay attention to the specifiers of class members of a superclass. • Access private members is not easy. 1/11/2022 Dayou Li / Marc Conrad 5
POLYMORPHISM • Very original meaning -- Microorganism propagates itself and no two individuals are exactly the same. So we obtain a variety of individuals. • Original meaning -- the sender of a stimulus doesn’t need to know the receiver’s class. • Extension -- different receivers can interpret the message in their own way. • Consequence -- different receivers can response to the same stimulus based on their interpretation. So we can have a variety of objects who process the same piece of data in different ways. • Method overloading and overwriting. 1/11/2022 Dayou Li / Marc Conrad 6
ENCAPSULATION • Encapsulation is the process of hiding the implementation details of an object. • The only access to manipulate the object data is through its interface. • It protects an object’s internal state from being corrupted by other objects. • Also, other objects are protected from changes in the object implementation. • Encapsulation allows objects to be viewed as ‘black boxes’. • Communication is achieved through an ‘interface’. 1/11/2022 Dayou Li / Marc Conrad 7
ANALYSIS • In software engineering, analysis is the process of converting the user requirements to system specification (system means the software to be developed). • System specification, also known as the logic structure, is the developer’s view of the system. • Function-oriented analysis -- concentrating to the decomposition a complex function to simply ones. • Object-oriented analysis -- identifying objects and the relationship between objects. (An objectoriented model of a system consists of a number of objects which are the parts of the system. ) 1/11/2022 Dayou Li / Marc Conrad 8
OO ANALYSIS • OO analysis contains the following activities: -- identifying objects: objects must be essential, i. e. always exist, so the system is stable, -- organising the objects: classifying the objects identified, so similar objects can later be defined in the same class, -- identifying relationships between objects: this helps to determine inputs and outputs of an object, -- defining operations of the objects: the way of processing data within an object, -- defining objects internally: information held be the objects. 1/11/2022 Dayou Li / Marc Conrad 9
OO ANALYSIS MODEL • A model is required to represent the system specification. • The model must be robust and stable. To achieve these, the model must be implementation environment independent, so that any change in the implementation environment will not affect the logic structure of the system. • The model must be able to capture information, behaviour (operations) and presentation (inputs and outputs). 1/11/2022 Dayou Li / Marc Conrad 10
OO ANALYSIS MODEL • The model is defined in information -- behaviour -presentation space. behaviour information presentation 1/11/2022 Dayou Li / Marc Conrad 11
OO ANALYSIS MODEL (Cont’d) Syntax • Within an use case, we employ three types of objects (in Rational Rose, they are known as three types of entities or stereotypes): Entity On information -- behaviour plane and incline to information axis Boundary / Interface Control 1/11/2022 On the presentation axis On information -- behaviour plane but incline towards behaviour axis Dayou Li / Marc Conrad 12
OO ANALYSIS MODEL (Cont’d) Semantics • An entity object models information that shows the state of a system. This information is often used to record the effects of operations and therefore is related to the behaviours of the system. • A boundary/interface object models inputs and outputs and operations that process them. • A Control object models functionality/operations regarding to validate and decide whether to process and pass information from interface object to entity object, or the way around. 1/11/2022 Dayou Li / Marc Conrad 13
OO ANALYSIS MODEL (Cont’d) Pragmatics • Identifying interface objects -- functions directly related to actors. • Identifying entity objects -- information used in an use case and functions of processing the information. • Identifying control object -- functions that link interface objects and entity objects 1/11/2022 Dayou Li / Marc Conrad 14
OO ANALYSIS MODEL (Cont’d) Example: Recycling machine • Three tasks are often tangled together • We normally start from the refinement of the use case diagram. • Then we identify objects. • At the “same time”, we organise and identify relationships. 1/11/2022 Dayou Li / Marc Conrad 15
OO ANALYSIS MODEL (Cont’d) • Refinement of the use case diagram -- Refine use cases by considering include, extend and generalisation. lu c in > e> d << Return item 1/11/2022 Print << in clu de >> Generating daily report Dayou Li / Marc Conrad 16
OO ANALYSIS MODEL (Cont’d) -- Refine actors by considering superclass/subclass and inheritance. a rit he in e nc Receipt receiverin he nc e Operator Customer 1/11/2022 rita Dayou Li / Marc Conrad 17
OO ANALYSIS MODEL (Cont’d) -- Refinement also includes adding use cases which are “forgotten” at the previous stage. Print Gene D Report Customer Return item Operator Change item Handle alarm 1/11/2022 Dayou Li / Marc Conrad R Receiver 18
OO ANALYSIS MODEL (Cont’d) • Identify boundary/interface objects R Receiver Receipt printer Operator panel Customer Operator Customer panel Alarm 1/11/2022 Dayou Li / Marc Conrad 19
OO ANALYSIS MODEL (Cont’d) • Identify relationship (also know as association) between the identified objects. Receipt printer Operator panel Customer panel Alarm 1/11/2022 Dayou Li / Marc Conrad 20
OO ANALYSIS MODEL (Cont’d) When a customer returns a deposit item, it is measured by the system. The measurements are used to determine what kind of can, bottle or crate has been returned. If acceptable, the total number of items of this type returned by the customer increments. If not, the light for “Not Valid” is highlighted on customer panel. When the customer presses the receipt button, the printer prints the date. The total number of items he returned and the lump sum is calculated. The following is printed out: customer number, number returned, deposit value, total of this type and lump sum 1/11/2022 Dayou Li / Marc Conrad 21
OO ANALYSIS MODEL (Cont’d) • Identify entity objects. (Let us focus on return item use case. ) -- long term information (for all customer): deposit values of bottle, can and crate, -- short term information (for a customer): the total number of items of each type returned by the customer, the total number of items he returned and the lump sum should be paid to him. 1/11/2022 Dayou Li / Marc Conrad 22
OO ANALYSIS MODEL (Cont’d) Generalisation Deposit items Receipt basis Storing short term info Can Bottle Crate Storing long term info 1/11/2022 Dayou Li / Marc Conrad 23
OO ANALYSIS MODEL (Cont’d) When a customer returns a deposit item, it is measured by the system. The measurements are used to determine what kind of can, bottle or crate has been returned. If acceptable, the total number of items of this type returned by the customer increments. If not, the light for “Not Valid” is highlighted on customer panel. When the customer presses the receipt button, the printer prints the date. The total number of items he returned and the lump sum is calculated. The following is printed out: customer number, number returned, deposit value, total of this type and lump sum 1/11/2022 Dayou Li / Marc Conrad 24
OO ANALYSIS MODEL (Cont’d) • Identify control objects. (We still focus on return item use case. ) -- There are entity and boundary objects in this use case. -- Items coming from customer panel need to be measured and decision on whether passing the information needs to be made according the measurement. -- decision on whether print out information also needs to be made. 1/11/2022 Dayou Li / Marc Conrad 25
OO ANALYSIS MODEL (Cont’d) deposit item receiver Receipt printer Customer panel receipt basis deposit items 1/11/2022 Dayou Li / Marc Conrad 26
OO ANALYSIS MODEL (Cont’d) Customer panel Deposit item receiver Deposit items Receipt basis can 1/11/2022 Receipt printer bottle Dayou Li / Marc Conrad crate 27
SUMMARY • Class and object • Analysis model 1/11/2022 Dayou Li / Marc Conrad 28
- Slides: 28