Chapter 2. Object Oriented Concepts and Modeling
Chapter 2. Object Oriented Concepts and Modeling
Encapsulation:
Encapsulation is an ability to bind (package) functions and data together in a place and hide
(or prevent) the data from unauthorized use from other parts of the program.
Thus, function and data in OOP are always together within an object that provides data
hiding, also known as encapsulation. Thus, data is hidden within an object.
It enables data hiding, hiding irrelevant information from the users of a class and exposing
only the relevant details required by the user. We can expose our operations to the outside
world and hide the details of what is needed to perform that operation. We can thus protect
the internal state of an object by hiding its attributes from the outside world.
Example from real world: Consider the smart phone you are using now. You are not
worried about the internal operations of the smart phone. You only know and care about
the operations or functions it exposes to you such as making call, sending SMS or using
your apps.
Data Abstraction:
Abstraction refers to an act of representing essential features without including background
details or explanations. Thus, data abstraction is methodology that supports use of
compound or complex object without its detail knowledge.
For example, a class car would be made up of engine, gearbox, steering objects and many
more components. To build car class, one does not need to know how the different
components of the car work internally, but only how to interface with them.
The OOA phase deals with the investigation of the problem and requirements, rather than
finding a solution to the problem.
The phase of OOA the typical question starts with what...? Like
₋ “What will my program need to do?”
₋ “What will the classes in my program be?” and
₋ “What will each class be responsible for?”
Priority is given to find and describe the objects or concepts in the problem domain.
Object oriented analysis emphasizes the building of real-world model using the object oriented
view of the world.
Object Oriented Analysis includes following activities:
₋ Finding the objects
₋ Organizing the objects
₋ Describing how the object interacts
₋ Defining the operations of the objects
₋ Defining the objects internally
Selection characteristics that should be used when considering each potential object for inclusion
in the analysis model:
1. Retained information: The potential object will be useful during analysis only if information
about it must be remembered so that the system can function.
2. Needed services: The potential object must have a set of identifiable operations that can
change the value of its attributes in some way.
3. Multiple attributes: During requirement analysis, the focus should be on "major"
information; an object with a single attribute may, in fact, be useful during design, but is
probably better represented as an attribute of another object during the analysis activity.
4. Common attributes: A set of attributes can be defined for the potential object and these
attributes apply to all occurrences of the object.
5. Common operations: A set of operations can be defined for the potential object and these
operations apply to all occurrences of the object.
6. Essential requirements: External entities that appear in the problem space and produce or
consume information essential to the operation of any solution for the system will almost
always be defined as objects in the requirements model
To be a legitimate object for inclusion in the requirements model, a potential object should
satisfy all (or almost all) of these characteristics.
The decision for inclusion of potential objects in the analysis model is somewhat subjective
Applying these selection characteristics to the list of potential SafeHome objects gives:
Specifying the Attributes
Attributes describe an object that has been selected for inclusion in the analysis model. In
essence, it is the attributes that define the object—that clarify what is meant by the object
in the context of the problem space.
To determine object attributes:
o Study the processing narrative (or statement of scope) for the problem and select
those things that reasonably "belong" to the object.
o Answer the following question for each object: "What data items (composite and/or
elementary) fully define this object in the context of the problem at hand?"
Defining Operations
Operations change one or more attribute values that are contained within an object.
Three categories of objects:
i. Operations that manipulate data in some way (e.g., adding, deleting, reformatting,
selecting)
ii. Operations that perform a computation
iii. Operations that monitor an object for the occurrence of a controlling event.
To derive a set of operations for the objects of the analysis model, study the processing
narrative (or statement of scope) for the problem and select those operations that
reasonably belong to the object.
o Study the grammatical parse again to isolate verbs.
o Some verbs will be legitimate operations and can be easily connected to a specific
object.
o e.g. from SafeHome processing narrative:
₋ "sensor is assigned a number and type"
₋ "A master password is programmed for arming and disarming the system."
o These two phrases indicate a number of things:
₋ An assign operation is relevant for the sensor object.
₋ A program operation will be applied to the system object.
o Also consider communication between objects.
Finalizing the Object Definition
Definition of operations is the last step in completing the specification of an object.
Generic life history of an object can be defined by recognizing that the object must be
created, modified, manipulated or read in other ways, and possibly deleted.
Some of the operations can be ascertained from likely communication between objects.
e.g.:
o sensor event will send a message to system to display the event
location and number
o control panel will send system a reset message to update system status
o audible alarm will send a query message
o control panel will send a modify message to change one or more attributes without
reconfiguring the entire system object;
o Sensor event will also send a message to call the phone number(s) contained in the
object.
Final Result
Example of candidate objects
Just a Line management wishes to increase security, both in their building and on site, without
antagonizing their employees. They would also like to prevent people who are not part of the company
from using the Just a Line car park.
It has been decide to issue identity cards to all employees, which they are expected to wear while on the
Just a Line site. The cards records the name, department and number of the member of staff, and permit
access to the Just a Line car park.
A barrier and a card reader are placed at the entrance to the car park. The driver of an approaching car
insert his or her numbered card in the card reader, which then checks that the card number is known to
the Just a Line system. If the card is recognized, the reader sends a signal to raise the barrier and the car
is able to enter the car park.
At the exit, there is also a barrier, which is raised when a car wishes to leave the car park.
When there are no spaces in the car park a sign at the entrance display “Full” and is only switched off
when a car leaves.
Special visitor’s cards, which record a number and the current date, also permit access to the car park.
Visitor’s cards may be sent out in advance, or collected from reception. All visitor’s cards must be
returned to reception when the visitor leaves Just a Line.