Lecture 1 - Introduction To OOP

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 53

LECTURER: KEN MBUKI

And though your beginning was


small, your latter days will be
very great.
Job 8:7
2
OOP: INTRODUCTION
HISTORY
Brief History
The first object–oriented language was Simula (Simulation of real
systems) that was developed in 1960 by researchers at the
Norwegian Computing Center.

In 1970, Alan Kay and his research group at Xerox PARK created a
personal computer named Dynabook and the first pure object-
oriented programming language (OOPL) - Smalltalk, for
programming the Dynabook.
Grandfather of Human-Centered Design
Brief History

In the 1980s, Grady Booch published a paper titled “Object


Oriented Design” that mainly presented a design for the
programming language, Ada.

In the ensuing editions, he extended his ideas to a complete


object–oriented design method.
Brief History
• In the 1990s, COAD incorporated behavioural ideas to
object-oriented methods.
• The other significant innovations were:
• Object Modelling Techniques (OMT) by James
Rumbaugh.
• Object-Oriented Software Engineering (OOSE) by
Ivar Jacobson.
Grandfather of Human-Centered Design
Evolution of OOP
• Before OOP many programming approaches existed
which had many drawbacks
Monolithic Programming Approach
• The program consists of sequence of statements that
modify data.
• Program control is achieved through the use of jumps
i.e. goto statements.
• Code is duplicated each time because there is no
support for the function.
• The programming languages like ASSEMBLY and BASIC
follow this approach.
Procedural Programming Approach

• This approach is top down approach.


• A program is divided into functions that perform a specific task.
Data is global and all the functions can access the global data.
• Program flow control is achieved through function calls and goto
statements. This approach is mainly used for medium sized
applications.
• The programming languages: FORTRAN and COBOL follow this
approach.
Structured Programming Approach
• The basic principal of structured programming approach is to
divide a program in functions and modules.
• The use of modules and functions makes the program more
comprehensible (understandable).
• It focuses on the development of large software applications.
• The programming languages: PASCAL and C follow this
approach.
Object Oriented Programming
Approach
• OOP approach seeks to remove the drawbacks of
conventional approaches.
• The basic principal of the OOP approach is to combine
both data and functions so that both can operate into a
single unit. Such a unit is called an Object. This approach
secures data also.
• The programming languages: C++ and JAVA follow this
approach. Using this approach we can write any lengthy
code.
OOP: INTRODUCTION
3 LEVELS OF PROGRAMMING
LANGUAGES
Machine level Language
• Machine code or machine language is a set of
instructions executed directly by a computer's central
processing unit (CPU).
• Each instruction performs a very specific task, such as a
load, a jump, or an ALU operation on a unit of data in a
CPU register or memory.
• Every program directly executed by a CPU is made up of
a series of such instructions.
Assembly level Language
• An assembly language (or assembler language) is a low-level
programming language for a computer, or other
programmable device, in which there is a very strong
(generally one-to-one) correspondence between the
language and the architecture's machine code instructions.
• Assembly language is converted into executable machine
code by a utility program referred to as an assembler; the
conversion process is referred to as assembly, or assembling
the code.
High level Language
• High-level language is any programming language that
enables development of a program in much simpler
programming context and is generally independent of
the computer's hardware architecture.
• High-level language has a higher level of abstraction
from the computer, and focuses more on the
programming logic rather than the underlying hardware
components such as memory addressing and register
utilization.
High level Language
• The high-level programming languages are broadly
categorized in to two categories:

• Procedure oriented programming(POP) language.

• Object oriented programming(OOP) language.


Procedural Oriented Programming
• Procedure oriented programming basically consist of writing
a list of instruction or actions for the computer to follow and
organizing these instruction into groups known as functions.
Characteristics of procedure
oriented programming:
a) Emphasis is on doing things(algorithm)
b) Large programs are divided into smaller programs
known as functions.
c) Most of the functions share global data
d) Data move openly around the system from function to
function
e) Function transforms data from one form to another.
f) Employs top-down approach in program design
Object Oriented Programming
“…a method of design encompassing the

process of object-oriented decomposition

and a notation for depicting both logical

and physical as well as static and dynamic

models of the system under design”.

Grady Booch
Object Oriented Programming

Add a footer 28
Features of the Object Oriented
programming

a) Emphasis is on doing rather than procedure.


b) Programs are divided into what are known as objects.
c) Data structures are designed such that they
characterize the objects.
d) Functions that operate on the data of an object are
tied together in the data structure.

Add a footer 29
OOP: INTRODUCTION
CONCEPTS AND TERMINOLOGIES
Objects
• An object is a real-world element in an object–oriented
environment that may have a physical or a conceptual existence.

Each object has −


1. Identity that distinguishes it from other objects in the
system.
2. State that determines the characteristic properties of an
object as well as the values of the properties that the object
holds.
3. Behavior that represents externally visible activities
performed by an object in terms of changes in its state.
Classes
A class represents a collection of objects having
same characteristic properties that exhibit common
behavior.

•It gives the blueprint or description of the objects


that can be created from it.
• Creation of an object as a member of a class is
called instantiation. Thus, object is an instance of a
class.
Classes
The constituents of a class are −
• A set of attributes for the objects that are to be
instantiated from the class. Attributes are often
referred as class data.
• A set of operations that portray the behavior of the
objects of the class. Operations are also referred as
functions or methods.
Class
Grandfather of Human-Centered Design
Data Abstraction
Abstraction refers to the act of representing essential
features without including the back ground details or
explanations.

Classes use the concept of abstraction and are defined as


size, width and cost and functions to operate on the
attributes.
Encapsulation
Encapsulation is the process of binding both attributes
and methods together within a class.

• Through encapsulation, the internal details of a class


can be hidden from outside.
• It permits the elements of the class to be accessed
from outside only through the interface provided by
the class.
Polymorphism

Polymorphism is originally a Greek word that means the ability to


take multiple forms.

• In object-oriented paradigm, polymorphism implies using


operations in different ways, depending upon the instance they
are operating upon.
• Polymorphism allows objects with different internal structures
to have a common external interface.
• Polymorphism is particularly effective while implementing
inheritance.
Types of Polymorphism
Inheritance

Inheritance is the mechanism that permits new classes to be created


out of existing classes by extending and refining its capabilities.
• The existing classes are called the base classes/parent classes/super-
classes, and the new classes are called the derived classes/child
classes/subclasses.
• The subclass can inherit or derive the attributes and methods of the
super-class(es) provided that the super-class allows so.
• Besides, the subclass may add its own attributes and methods and
may modify any of the super-class methods.
Inheritance
Example
From a class Mammal, a number of
classes can be derived such as Human,
Cat, Dog, Cow, etc.

Humans, cats, dogs, and cows all have


the distinct characteristics of
mammals.

In addition, each has its own


particular characteristics.
Types of Inheritance
1. Single Inheritance − A subclass derives from a single super-
class.
2. Multiple Inheritance − A subclass derives from more than one
super-classes.
3. Multilevel Inheritance − A subclass derives from a super-class
which in turn is derived from another class and so on.
4. Hierarchical Inheritance − A class has a number of subclasses
each of which may have subsequent subclasses, continuing for
a number of levels, so as to form a tree structure.
5. Hybrid Inheritance − A combination of multiple and multilevel
inheritance so as to form a lattice structure
Dynamic Binding
Binding refers to the linking of a procedure call to the
code to the executed in response to the call.

Dynamic binding means the code associated with a


given procedure call is not known until the time of the
call at run-time.

It is associated with a polymorphic reference depends


upon the dynamic type of that reference.
Message Passing

A message for an object is a request for execution


of a procedure and therefore will invoke a
function (procedure) in the receiving object that
generates the desired result.
Message passing involves specifying the name of
the object, the name of the function (message)
and information to be sent.
Message Passing
Personal Reading
• Benefits of OOP
• Applications of OOP
• More OOP Concepts: Links,
aggregation, association,
composition, generalization
and specialization

Add a footer 47
Reference Materials
Reference Materials

4 Principles of Object-Oriented Programming


https://khalilstemmler.com/articles/object-
oriented/programming/4-principles/

How Object-Oriented Programming Started


http://kristennygaard.org/FORSKNINGSDOK_MAPPE/F_
OO_start.html
Add a footer 49
Reference Materials
Object Oriented Programming
BOOK -
https://www.researchgate.net/publication/327285381_
Object_Oriented_Programming#:~:text=Proper%20objec
t%2Doriented%20design%20practices,worked%2Dout%
20examples%20and%20programs

Add a footer 50
Reference Materials
Conference Paper

POSSIBILITIES OF USING GAMES IN TEACHING AND LEARNING THE


BASIC CONCEPTS OF OBJECT-ORIENTED PROGRAMMING

See:
https://www.researchgate.net/publication/369565621_POSSIBILITIES_OF_U
SING_GAMES_IN_TEACHING_AND_LEARNING_THE_BASIC_CONCEPTS_
OF_OBJECT-ORIENTED_PROGRAMMING

Add a footer 51
Next week

Object Model, Dynamic and


Functional Modelling
THANKS!
Any questions?

You can reach me at


Email: jmbuki@kcau.ac.ke

Add a footer 53

You might also like