0% found this document useful (0 votes)
45 views6 pages

OOPChapter 01

The document discusses object-oriented programming including its definition, structure, principles, examples of languages, benefits and criticisms. OOP organizes programs around data objects that contain both data fields and methods. Key concepts covered include classes, objects, methods, attributes, encapsulation, abstraction, inheritance and polymorphism.

Uploaded by

gemechu gebisa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views6 pages

OOPChapter 01

The document discusses object-oriented programming including its definition, structure, principles, examples of languages, benefits and criticisms. OOP organizes programs around data objects that contain both data fields and methods. Key concepts covered include classes, objects, methods, attributes, encapsulation, abstraction, inheritance and polymorphism.

Uploaded by

gemechu gebisa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

New Generation University College

Center for Excellence


Department of Computer Science
Program Regular/Extension/Weekend
Course Title: Object Oriented Programming
Chapter One: Introduction to Object oriented programming (OOP) ---------4hr
1.1 What is object-oriented programming?
Object-oriented programming (OOP) is a computer programming model that organizes software
design around data, or objects, rather than functions and logic. An object can be defined as a data
field that has unique attributes and behavior. OOP focuses on the objects that developers want to
manipulate rather than the logic required manipulating them. This approach to programming is
well-suited for programs that are large, complex and actively updated or maintained. This
includes programs for manufacturing and design, as well as mobile applications; for example,
OOP can be used for manufacturing system simulation software.
The organization of an object-oriented program also makes the method beneficial to
collaborative development, where projects are divided into groups. Additional benefits of OOP
include code reusability, scalability and efficiency.
The first step in OOP is to collect all of the objects a programmer wants to manipulate and
identify how they relate to each other -- an exercise known as data modeling.
Examples of an object can range from physical entities, such as a human being who is described
by properties like name and address.

Once an object is known, it is labeled with a class of objects that defines the kind of data it
contains and any logic sequences that can manipulate it. Each distinct logic sequence is known as
a method. Objects can communicate with well-defined interfaces called messages.

1 By Keresa G(Msc) [email protected] V2/2015/22


1.2 structure of object-oriented programming
The structure, or building blocks, of object-oriented programming include the following:
 Classes are user-defined data types that act as the blueprint for individual objects, attributes
and methods.

 Objects are instances of a class created with specifically defined data. Objects can correspond
to real-world objects or an abstract entity. When class is defined initially, the description is the
only object that is defined.

 Methods are functions that are defined inside a class that describe the behaviors of an object.
Each method contained in class definitions starts with a reference to an instance object.
Additionally, the subroutines contained in an object are called instance methods. Programmers
use methods for reusability or keeping functionality encapsulated inside one object at a time.

 Attributes are defined in the class template and represent the state of an object. Objects will
have data stored in the attributes field. Class attributes belong to the class itself.

This image shows an example of the structure and naming in OOP.


1.3 principles of OOP
Object-oriented programming is based on the following principles:
 Encapsulation. This principle states that all important information is contained inside an
object and only select information is exposed. The implementation and state of each object are
privately held inside a defined class. Other objects do not have access to this class or the
authority to make changes. They are only able to call a list of public functions or methods.

2 By Keresa G(Msc) [email protected] V2/2015/22


This characteristic of data hiding provides greater program security and avoids unintended
data corruption.

 Abstraction. Objects only reveal internal mechanisms that are relevant for the use of other
objects, hiding any unnecessary implementation code. The derived class can have its
functionality extended. This concept can help developers more easily make additional changes
or additions over time.

 Inheritance. Classes can reuse code from other classes. Relationships and subclasses between
objects can be assigned, enabling developers to reuse common logic while still maintaining a
unique hierarchy. This property of OOP forces a more thorough data analysis, reduces
development time and ensures a higher level of accuracy.

 Polymorphism. Objects are designed to share behaviors and they can take on more than one
form. The program will determine which meaning or usage is necessary for each execution of
that object from a parent class, reducing the need to duplicate code. A child class is then
created, which extends the functionality of the parent class. Polymorphism allows different
types of objects to pass through the same interface.

1.4 Examples of object-oriented programming languages


For example, programming languages considered pure OOP languages treat everything as
objects. Other programming languages are designed primarily for OOP, but with some
procedural processes included.
Programming languages designed primarily for OOP include:
 Java  Visual Basic .NET
 Python  PHP
 C++  JavaScript
1.6 Benefits of OOP?

 Modularity. Encapsulation enables objects to be self-contained, making troubleshooting and


collaborative development easier.

 Reusability. Code can be reused through inheritance, meaning a team does not have to write
the same code multiple times.

 Productivity. Programmers can construct new programs quicker through the use of multiple
libraries and reusable code.

3 By Keresa G(Msc) [email protected] V2/2015/22


 Easily upgradable and scalable. Programmers can implement system functionalities
independently.

 Interface descriptions. Descriptions of external systems are simple, due to message passing
techniques that are used for objects communication.

 Security. Using encapsulation and abstraction, complex code is hidden, software maintenance
is easier and internet protocols are protected.

 Flexibility. Polymorphism enables a single function to adapt to the class it is placed in.
Different objects can also pass through the same interface.

1.7 Criticism of OOP


The object-oriented programming model has been criticized by developers for multiple reasons.
The largest concern is that OOP overemphasizes the data component of software development
and does not focus enough on computation or algorithms. Additionally, OOP code may be more
complicated to write and take longer to compile.
Alternative methods to OOP include:

 Functional programming. This includes languages such as Erlang and Scala, which are used
for telecommunications and fault tolerant systems.

 Structured or modular programming. This includes languages such as PHP and C#.

 Imperative programming. This alternative to OOP focuses on function rather than models
and includes C++ and Java.

 Declarative programming. This programming method involves statements on what the task
or desired outcome is but not how to achieve it. Languages include Prolog and Lisp.

 Logical programming. This method, which is based mostly in formal logic and uses
languages such as Prolog, contains a set of sentences that express facts or rules about a
problem domain. It focuses on tasks that can benefit from rule-based logical queries.

Most advanced programming languages enable developers to combine models, because they can
be used for different programming methods. For example, JavaScript can be used for OOP and
functional programming.

4 By Keresa G(Msc) [email protected] V2/2015/22


Differences between Procedural and Object Oriented Programming

A. Procedural Programming

Procedural Programming can be defined as a programming model which is derived from


structured programming, based upon the concept of calling procedure. Procedures, also known as
routines, subroutines or functions, simply consist of a series of computational steps to be carried
out. During a program’s execution, any given procedure might be called at any point, including
by other procedures or itself.
Languages used in Procedural Programming:
FORTRAN, ALGOL, COBOL, BASIC, Pascal and C.

B. Object-Oriented Programming

Object-oriented programming can be defined as a programming model which is based upon the
concept of objects. Objects contain data in the form of attributes and code in the form of
methods. In object-oriented programming, computer programs are designed using the concept of
objects that interact with the real world. Object-oriented programming languages are various but
the most popular ones are class-based, meaning that objects are instances of classes, which also
determine their types.
Languages used in Object-Oriented Programming:
Java, C++, C#, Python, PHP, JavaScript, Ruby, Perl, Objective-C, Dart, Swift, Scala.

Procedural Programming vs Object-Oriented Programming

Below are some of the differences between procedural and object-oriented programming:

Procedural Oriented Programming Object-Oriented Programming

In procedural programming, the program is In object-oriented programming, the program


divided into small parts called functions. is divided into small parts called objects.

Procedural programming follows a top-down Object-oriented programming follows


approach. a bottom-up approach.

There is no access specifier in procedural Object-oriented programming has access


programming. specifiers like private, public, protected, etc.

5 By Keresa G(Msc) [email protected] V2/2015/22


Procedural Oriented Programming Object-Oriented Programming

Adding new data and functions is not easy. Adding new data and function is easy.

Procedural programming does not have any Object-oriented programming provides data
proper way of hiding data so it is less secure. hiding so it is more secure.

In procedural programming, overloading is not Overloading is possible in object-oriented


possible. programming.

In procedural programming, there is no concept In object-oriented programming, the concept


of data hiding and inheritance. of data hiding and inheritance is used.

In procedural programming, the function is In object-oriented programming, data is more


more important than the data. important than function.

Procedural programming is based on the unreal Object-oriented programming is based on


world. the real world.

Procedural programming is used for designing Object-oriented programming is used for


medium-sized programs. designing large and complex programs.

Procedural programming uses the concept of Object-oriented programming uses the concept
procedure abstraction. of data abstraction.

Code reusability absent in procedural Code reusability present in object-oriented


programming, programming.

Examples: C, FORTRAN, Pascal, Basic, etc. Examples: C++, Java, Python, C#, etc.

End of Chapter One

6 By Keresa G(Msc) [email protected] V2/2015/22

You might also like