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

UNIVERSITY OF IRINGA

FACULTY OF SCIENCE AND EDUCATION


DEPARTMENT OF INFORMATION TECHNOLOGY

LECTURE ONE
INTRODUCTION TO OBJET-ORIENTED
PROGRAMMING

Reg, No. Course Year


DIT 206 Introduction to OOP 2018/ 2019

Ass. Lecturer: Thobius Joseph (M.Sc. In Telecom Eng.)


Date: Nov, 2018

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


CONTENTS

1. Introduction to OOP

2. Principles of OOP

3. Application of OOP

4. Assignment

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Introduction of OOP
 We have many programming pattern (paradigm)
1. Sequential programming
2. Structural programming
3. Functional programming
4. Event Driven (or Oriented) programming
5. Object- Oriented Programming (OOP)
and etc…
 For OOP pattern (Paradigm)
 We are programming our software's program by using concept of
objects. By using concept of objects it meaning we are grouping
our data and functions (to be operated to that data) as single unit
(objects).
 In the environment of the artificial intelligence group, as early as
1960, "object" could refer to identified items with properties
(attributes).

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Introduction of OOP
 These objects (identified items) in programming (which
actually is just a block of code) has a well defined
1. Name of object which known as Identity
2. A block of code which hold values which known as Fields or
data fields or often known as attributes or state.
3. A block of code that take input, generate output and
manipulate data which known as methods or behavior or
function or routines or subroutines.
 In OOP, in order to interact with object fields such as to
access data or modify data of object , we need to use object
procedures or methods.

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Introduction of OOP
 These is different versions (diversity) of OOP languages;
 Examples:
1. OOP that uses classes called Classed-based programming
2. OOP that do not typically use classes called Prototype-based programming
 In class-based languages the classes are defined beforehand and the objects are
instantiated based on the classes. If two objects apple and orange are instantiated
from the class Fruit, they are inherently fruits and it is guaranteed that you may handle
them in the same way; e.g. a programmer can expect the existence of the same
attributes such as color or sugar content or is ripe.
 In prototype-based languages the objects are the primary entities. No classes even
exist. The prototype of an object is just another object to which the object is linked.
Every object has one prototype link (and only one). New objects can be created based
on already existing objects chosen as their prototype. You may call two different
objects apple and orange a fruit, if the object fruit exists, and both apple and orange
have fruit as their prototype. The idea of the fruit class doesn't exist explicitly, but as
the equivalence class of the objects sharing the same prototype. The attributes and
methods of the prototype are delegated to all the objects of the equivalence class
defined by this prototype. The attributes and methods owned individually by the
object may not be shared by other objects of the same equivalence class; e.g. the
attributes sugar content may be unexpectedly not present in apple. Only single
inheritance can be implemented through the prototype.

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Introduction of OOP
NB: for sake of our course we will focus only with class-based OO
languages and because it’s a popular one.
 In this classed based OOP we are grouping objects according to
their type or class, therefore class is used as object data type.
 Here the criteria used for grouping objects in type or class is
assimilated characteristics, which are data and possible functions.
 Henceforth, the class may be defined as a group of objects with
similar attributes and behavior.
 Demonstration: Class of the following objects is
I. Chair and table = furniture
II. Mosquitos and Bee= Insect
III. Dogs and Got = Animal

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Principle (Features) of Object-Oriented languages(class-based)
 We have many programming languages and also we have many
ways of grouping (classifying) these languages such as low level and
high level or procedural, structural and object-oriented
programming languages.
 Some languages may strict in one group while others in may be
found in more than one group.
 For a languages to be within OOP languages group should at least
have the following principles or features:
I. Classes
II. Objects
III. Abstraction
IV. Inheritance
V. Encapsulation
VI. Polymorphism

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Classes
 Class is defined as the blueprint for an object. It may also
described as logical group of data (field) and functions that
can be performed to that group of data.
 This contain definitions for the data format and available
procedures for a given type or class of object; may also
contain data and procedures (known as class methods)
themselves, i.e. classes contain the data members and
member functions.
 Computer programmers will write a class because they want
to create objects.
 For example, a "Banana" class would represent the properties
and functionality of bananas in general. A single, particular
banana(ndizi kisukari au ndizi bukoba) would be an instance
of the "Banana" class, an object of the type "Banana".

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Objects
 Objects are defined as the instances of a class. (mfano halisi
wa class)
 kama ndizi ni class, mifano halisi (objects in that class)
inaweza kuwa ndizi bukoba, ndizi mshale na ndizi kisukari
 object refers to a particular instance of a class, where the
object have unique identity, state (data ) and behavior (code)
 Objects (in real life as well as programming) can be physical
or conceptual;
Car, Bus, Plane
Monitor, Keyboard, Mouse
Employees, Students

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Abstraction
 As per dictionary, abstraction is the quality of dealing with
ideas rather than events. For example, when you consider the
case of e-mail, complex details such as what happens as soon
as you send an e-mail, the protocol your e-mail server uses
are hidden from the user. Therefore, to send an e-mail you
just need to type the content, mention the address of the
receiver, and click send.
 Likewise in Object-oriented programming, abstraction is a
process of hiding the implementation details from the user,
only the functionality will be provided to the user. In other
words, the user will have the information on what the object
does instead of how it does it.

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Abstraction

Can you classify the


followings
Elephant, CD player,
Television, Chair, Table, Tiger
How many classes do you
identify here?
11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724
Abstraction
The obvious answer anybody would give is three, i.e. Animal,
Furniture and Electronic items. But how do you come to this
conclusion? Well, we grouped similar items by focusing on the
generic characteristics rather than specific characteristics. This is
abstraction.
 In programming, we manage complexity by concentrating
only on the essential characteristics and suppressing
implementation details.

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Inheritance
 Is the way to adopt the characteristics of a class into another class.
 Inheritance can be defined as the process where one class acquires the
properties (methods and fields) of another. With the use of inheritance
the information is made manageable in a hierarchical order.
 Here we have two types of class: 1. Base class
2. Subclass
 Subclass inherits all the properties of a base class, but also it can add its
own features(properties and behavior).
 The class which inherits the properties of other is known as subclass
(derived class, child class) and the class whose properties are inherited is
known as superclass (base class, parent class).
 The principle of dividing a class into subclass is that each subclass shares
common characteristics with the class from which they are inherited or
derived. Cars, scooters, planes, and ships all have an engine and
speedometer. These are the characteristics of vehicles. Each subclass has
its own characteristics features, e.g. motorcycles have disk braking
system, while planes have hydraulic braking system. A car can run only on
the surface, while a plane can fly in air and ship sails over water.

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Inheritance
 This feature assist in reusability, meaning you can use other
class in your program. This is similar to use library functions in
procedural languages

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Encapsulation
 Also known as data hiding.
 Is the process of binding the data procedures into objects to hide them from the
outside world. It provides us the power to restrict anyone from directly altering
our data.
 Encapsulation is one of the four fundamental or pillars OOP concepts. The other
three are inheritance, polymorphism, and abstraction.
 Any access to the data has to be through the methods of the class. The details
that are not useful for others objects should be hidden from them
 Foe example, an object that does the calculation must provide an interface to
obtain the result. However, the internal coding used to calculate need not be
made available to the requesting object.

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Polymorphism
 Polymorphism is the ability of an object to take on many forms.
The most common use of polymorphism in OOP occurs when a
parent class reference is used to refer to a child class object.
 In programming, we have two polymorphism: compile-time and
runtime polymorphism. Compile-time polymorphism in Java is
implemented by overloading and runtime by overriding.
 In overloading, a method has the same name with different
signatures. A signature is the list of formal argument passes to the
method.
 In overriding, a method is defined in subclass with the same name
and same signature.
 This distinction between compile-time and runtime polymorphism
is of method invocation. In case of compile-time, the compiler
determine which method (from all the overloaded methods) will
be executed and when decision is delayed until runtime, then
overridden method will be executed and it’s a run-time
polymorphism.

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Polymorphism

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Application of OOP
In OOP, we access data with the help of objects, so it is very easy to overcome a problem without
modifying the whole system. Some of fields OOP is used are:

1. Client-Server Systems
Object-oriented Client-Server Systems provide the IT infrastructure, creating object-oriented Client-
Server Internet (OCSI) applications. Here, infrastructure refers to operating systems, networks, and
hardware. OSCI consist of three major technologies:

The Client Server


Object Oriented Programming
The Internet

2. Object Oriented Databases


They are also called Object Database Management Systems (ODBMS). These databases store objects
instead of data, such as real numbers and integers. Objects consist of the following:

Attributes: Attributes are data that defines the traits of an object. This data can be as simple as integers
and real numbers. It can also be a reference to a complex object.

Methods: They define the behavior and are also called functions or procedures.

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Application of OOP

3. Object Oriented Databases


These databases try to maintain a direct correspondence between the real-world and
database objects in order to let the object retain their identity and integrity. They can then
be identified and operated upon.

4. Real-Time System Design


Real time systems inherit complexities that makes difficult to build them. Object-oriented
techniques make it easier to handle those complexities. These techniques present ways of
dealing with these complexities by providing an integrated framework which includes
schedulability analysis and behavioral specifications.

5. Simulation And Modelling System


It’s difficult to model complex systems due to the varying specification of variables. These
are prevalent in medicine and in other areas of natural science, such as ecology, zoology,
and agronomic systems. Simulating complex systems requires modelling and
understanding interactions explicitly. Object-oriented Programming provides an alternative
approach for simplifying these complex modelling systems.

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Application of OOP

6. Hypertext And Hypermedia


OOP also helps in laying out a framework for Hypertext. Basically, hypertext is
similar to regular text as it can be stored, searched, and edited easily. The only
difference is that hypertext is text with pointers to other text as well.

Hypermedia, on the other hand, is a superset of hypertext. Documents having


hypermedia, not only contain links to other pieces of text and information, but
also to numerous other forms of media, ranging from images to sound.

7. Neural Networking And Parallel Programming


It addresses the problem of prediction and approximation of complex time-
varying systems. Firstly, the entire time-varying process is split into several time
intervals or slots. Then, neural networks are developed in a particular time
interval to disperse the load of various networks. OOP simplifies the entire
process by simplifying the approximation and prediction ability of networks.

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Application of OOP

8. Office Automation Systems


These include formal as well as informal electronic systems primarily concerned with information
sharing and communication to and from people inside as well as outside the organization. Some
examples are:
Email
Word processing
Web calendars
Desktop publishing

9. CIM/CAD/CAM Systems
OOP can also be used in manufacturing and design applications as it allows people to reduce the effort
involved. For instance, it can be used while designing blueprints, flowcharts, etc. OOP makes it possible
for the designers and engineers to produce these flowcharts and blueprints accurately.

10. AI Expert Systems


These are computer applications which are developed to solve complex problems pertaining to a
specific domain, which is at a level far beyond the reach of a human brain.

It has the following characteristics:

Reliable
Highly responsive
Understandable
High-performance

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


Assignment (Individual)
1. List features that OOP share with Non-OOP languages.
2. In programming when you told languages has the following
features:
1) Portable
2) Extensible
What does that means?
3. Differentiate the following programming terminologies based
on programming era:
1. Method
2. Function
3. Module

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724


THANKS IN ADVANCE!!

11/13/2018 Thobius Joseph(Msc in Eng.), 0783758724

You might also like