[go: up one dir, main page]

0% found this document useful (0 votes)
13 views13 pages

Oop

The document discusses two programming paradigms: procedural programming and object-oriented programming (OOP). It highlights the differences between the two, emphasizing that OOP encapsulates data and methods within classes and promotes concepts like inheritance, polymorphism, and encapsulation. Additionally, it outlines the benefits of OOP, such as ease of design, maintenance, and code reusability.

Uploaded by

smaugqwer
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)
13 views13 pages

Oop

The document discusses two programming paradigms: procedural programming and object-oriented programming (OOP). It highlights the differences between the two, emphasizing that OOP encapsulates data and methods within classes and promotes concepts like inheritance, polymorphism, and encapsulation. Additionally, it outlines the benefits of OOP, such as ease of design, maintenance, and code reusability.

Uploaded by

smaugqwer
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/ 13

Object

Oriented
Programming
JAVA PRORAMMING
Two approaches to writing computer programs:
Procedural programming

• A style of programming in which operations are executed one


after another in sequence.
• In procedural applications, you create names for computer
memory locations (variables) that can hold values for example,
numbers and text
• the individual operations used in a computer program are often
grouped into logical units called procedures.

• Procedures are also called modules, methods, functions, and


subroutines
Procedural-languages separate the data
structures (variables) and algorithms
(functions)

• FORTRAN
• BASIC (Beginners All-purpose Symbolic Instruction Code)
• ALGOL (ALGOrithmic Language
• Pascal
• COBOL (COmmon Business Oriented Language)
• C
Object Oriented Programming (OOP)
• Object-oriented programming is an extension of procedural
programming in which you take a slightly different approach
to writing computer programs.
• Writing object-oriented programs involves creating classes, which
are blueprints for objects.

• Objects are created from classes and creating applications using


objects

• The basic unit of OOP is a class, which encapsulates both the static
properties and dynamic operations within a "box", and specifies the
public interface for using these boxes
• OOP combines the data structures and algorithms of a software
entity inside the same box.
Object-oriented programming was used most frequently for two major
types of applications:

• Computer simulations, which attempt to mimic real-world activities so


that their processes can be improved or so that users can better
understand how the real-world processes operate

• Graphical user interfaces, or GUIs (pronounced “gooeys”), which


allow users to interact with a program in a graphical environment
Languages used in Object-Oriented Programming

• Java • Ruby
• C++ • Perl
• C# • Objective-C
• Python • Dart
• PHP • Swift
• JavaScript • Scala
Class and Objects
A class is the blueprint or template for its objects. Objects are instances
of a class.

Object-oriented terminology
• class is a term that describes a group or collection of objects with
common properties
• class definition describes what attributes its objects will have and what
those objects will be able to do

• Attributes are the characteristics that define an object; they are


properties of an object
• A method is a self contained block of program code that carries out
some action, similar to a procedure in a procedural program.
A class definition and some objects created from it
Three basic concepts of OOP

Polymorphism

I nheritance

E ncapsulation
Encapsulation refers to the hiding of data and methods within an object.
Encapsulation provides the security that keeps data and methods safe
from inadvertent changes.

The purpose of encapsulation is at least one of the following:

• Putting restrictions in place so that the components of an object


cannot be accessed directly

• Binding the data with methods that will act on that data
Inheritance the ability to create classes that share the attributes and
methods of existing classes

Polymorphism is generally associated with one name with many forms.

Two types of polymorphism


• Compile-time polymorphism: The compiler can decide very early which
method to invoke in which situation once the program is compiled. This
is also known as static binding or early binding.

• Runtime polymorphism: The actual method calls are resolved at runtime.


At compile time, you cannot predict which method will be invoked when
the program runs
Difference between Procedural Programming
and Object-Oriented Programming
PROCEDURAL ORIENTED PROGRAMMING OBJECT-ORIENTED PROGRAMMING
In procedural programming, program is In Object-Oriented Programming, program
divided into small parts called functions. is divided into small parts called objects.
Procedural programming follows top down Object oriented programming follows
approach. bottom up approach.
There is no access specifier in procedural Object-Oriented Programming have
programming. access specifiers like private, public,
protected etc.
Adding new data and function is not easy. Adding new data and function is easy.
Procedural programming does not have Object-Oriented Programming provides
any proper way for hiding data so it is less data hiding so it is more secure.
secure.
In procedural programming, overloading is Overloading is possible in object oriented
not possible. programming.
In procedural programming, function is In object oriented programming, data is
more important than data. more important than function.
Object-Oriented technology has many benefits
• Ease in software design as you could think in the problem space
rather than the machine's bits and bytes. You are dealing with high-
level concepts and abstractions. Ease in design leads to more
productive software development.
• Ease in software maintenance: object-oriented software is easier to
understand, therefore easier to test, debug, and maintain.
• Reusable software: you don't need to keep re-inventing the
wheels and re-write the same functions for different
situations. The fastest and safest way of developing a new
application is to reuse existing codes - fully tested and
proven codes

You might also like