to understand why we need object-oriented techniques
to introduce object-orientation concept
Topics :
Evolution in programming
why do system fail
basic ideas of object-orientatiom
what is object-oriented programming
classes and objects
abstraction
encapsulation
Instantiation
Ploymorphism
Inheritance
Evolution in programming
Handcrafted programming
pre-compiler era, mostly machine code
more of an art than science
Modular Programming
concept of subroutines
complex logic is broken down into maintanable fragments
require a lot of dicipline
Structured Programming
functional decomposition
top-down approach in programming design
consists of multiple levels of subroutines
emphasis on team-work of development
costly to change/maintain
Why do system fail?
Dynamic bussiness requirements
Complex modern information structure
Open, heregenous environment
Cost
Time
Need a New Approach in Software Development We need:
accurately model (changing) bussiness requirements
highly scalable
promote reusability
hide complexity
ease of maintanance/change
increase productivity
Basic ideas of object-orientation
The world is full of things
we abstract things and call the abstraction objects
we talk to object, not their parts
object can be
tangible
intangible
ex:
cheque
schedule
flight
What is Object-oriented Programming
A method of implementation in which programs are organized as cooperative
collections of objects, each of which represents an instance of some class,
and whose classes are all members of a hierarchy of classes united via
inheritance relationship.
Basic concepts of Object-oriented Programming
Classes and Objects
Abstraction
Encapsulation
Instantiation
Polymorphism
Inheritance
Classes and Objects
An object has state, behavior and identity
Identity
Property of an object which distinguishes it from other objects
State
The state of an object is held in object values
The object changes state whenever any of its variables change value
Behaviour
How an object acts and reacts in terms of its state changes and message
passing
Class
Description of set of objects with similar properties
A set of objects that share a common structure and a common behavior
Class name and its interface
Messages and Methods
Messages
sent to receiver object
message-send always returns an object
a message may include parameters
only way to communicate with an object
Methods
Has a name that is the same as message name
Determine how the object acts upon receiving the message
Is a sequence of executable statement
Returns an objects as its result of execution
Similar to a function call in traditional programming
Abstraction
The process of focusing on the essential, inherent aspects of an entity
and ignore its accidental. (Focus on what an objet does before deciding
how it should be implemented)
Encapsulation/Information Hiding
The process of hiding all of the details of an object that do not contribute
to its essential characteristics.
The warapping up of data and functions into a single unit(class)
The data is not accessible to the outside world and only functions which
are wrapped in the class can access it (information hiding)
Instantiation
A creation of an instance of a class
Only one class needs to be defined for one or more creation of class object
instances
Each instance is unique
Each instance has its own value for each attribute but share the attribute
names and operations with other instances of the class.
Polymorphism
The ability to take more than one form
An operation may exhibit different behaviour in different instances
Function Overloading
An operation may exhibit different behaviour in one instance based on the
argument send to it.
Example:
Fly();
Fly(200,50);
Fly(150);
Inheritance
The sharing of attribute and operations among classes based on a hierarchical
relationship
A class can be defined broadly and then refined into succesively finer
subclass
Subclasses
Inherits all of the properties of its superclasses and adds its own unique
properties