Object Oriented Concepts
Object Oriented Concepts
Object Oriented Concepts
Object Oriented
Concepts
Session outline
• Examples from the real world include a car, a person, a house, a table, a dog, a
patient…
• All objects have attributes: for example, a car has a manufacturer, a model
number, a color and a price
• Objects also have operations to perform: a car can move from one place to
another and a dog can bark.
• We’re not trying to simulate the real world, that would be far too difficult. we’re
simply trying to make sure that our software is influenced by real-world concepts,
so that it is easier to produce and easier to change
Depicting objects
• Examples of a class
• A factory manufactures objects according to some blueprint.
• A set specifies what features its member objects will have.
• A template allows us to produce any number of objects of a
given shape.
Attributes
• descriptive pieces of information about things or
objects
• For example, a customer has a name, a phone number,
a credit limit, and so on
What is an Attribute?
Object
Class
:CourseOffering
number = 104
startTime = 11:00
endTime = 12:00
Method/operation
• Is some action that one object performs upon another in order to
elicit a reaction
• For example a car moves, stops, turns…
What is an Operation?
CourseOffering
Class
addStudent
deleteStudent
getStartTime
Operation getEndTime
• Identify objects and classes from the
student information system.
Encapsulation
• Encapsulation refers to an object hiding its attributes behind its operations
• Hidden attributes are said to be private
• If we get direct access to attributes it would be much harder to change the internal
representation of the object in the future, because we’d have to find all the pieces of
code that access the attributes directly and change those too.
• Without encapsulation we would lose simplicity and locality.
• The more one class has to “know” about another class, the higher is the
coupling between them