LEC - 01 (OOP Basics)
LEC - 01 (OOP Basics)
modules.
Software re-use: where an application can be composed from
Objects
Encapsulation
Inheritance
Polymorphism
Abstraction
or a remote control).
We can still understand the concept of a television,
A class should:
Provide a well-defined interface - such as the remote control of
the television.
Represent a clear concept - such as the concept of a television.
television.
Unified Modelling
Language (UML)
representation of
the Television class for
object-oriented modelling
and programming.
Encapsulation is used to hide the mechanics of the object, allowing the actual
implementation of the object to be hidden. All we need to understand is the interface that
is provided for us.
For example, Television class, where the functionality of the television is hidden from us,
but we are provided with a remote control, or set of controls for interacting with the
television, providing a high level of abstraction.
There is no requirement to understand how the signal is decoded from the aerial and
converted into a picture to be displayed on the screen before you can use the television.
9
There is a sub-set of functionality that the user is allowed to call, termed the
interface.
What are the interfaces of a Car?
The full implementation of a class is the sum of the public interface plus the
private implementation.
Encapsulation is the term used to describe the way that the interface is
separated from the implementation.
Encapsulation as data-hiding
Allow certain parts of an object to be visible
User
Can change the implementation, but need not notify the user.
10
There is a sub-set of functionality that the user is allowed to call, termed the
interface.
What are the interfaces of a Car?
The full implementation of a class is the sum of the public interface plus the
private implementation.
Encapsulation is the term used to describe the way that the interface is
separated from the implementation.
Encapsulation as data-hiding
Allow certain parts of an object to be visible
User
Can change the implementation, but need not notify the user.
11
12
more accurately
webbed feet.
13
14
One way to determine that you have organized your classes correctly is
to check them using the "IS-A" and "IS-A-PART-OF" relationship
checks.
It is easy to confuse objects within a class and children of classes when
you first begin programming with an OOP methodology.
15
debugged
16
When a class inherits from another class it inherits both the states and
methods of that class, so in the case of the Car class inheriting from the
Vehicle class the Car class inherits the methods of the Vehicle class
engineStart(), gearChange(), lightsOn() etc.
Over-loading
17
18