Sunteți pe pagina 1din 3

OOP

What is object orientated programming?


Object orientated programming(OOP) refers to a type of computer programming
where programmers define not only the data type of the data structure, but also
the types of operations that can be applied to the data structure. An OOPL is an
object orientated programming language and to perform OOP one needs one of
these languages. Java, C++, Ruby and Smalltalk are all examples of an OOPL.
When it comes to projects large programs are quite difficult to write and object
orientated programs force designers to go through extensive planning, which in
turn makes for better designs with less flaws. OOPs are actually easier to
program once they reach a certain size compared to non-object orientated ones.
The Basics of OOP
Abstraction
Abstraction is the process of picking out or abstracting common features of
objects and procedures.
Class
This is a category of objects. The class defines all the common properties of the
different objects that belong to it.
Encapsulation
This is the process of combining elements to create a new entity. A procedure is
a type of encapsulation because it combines a series of computer instructions.
Information hiding
This is the process of hiding details of an object or function, it is a most powerful
programming technique as it reduces complexity.
Inheritance
This is a feature that represents the is a relationship between different classes.
Messaging
Message passing is a form of communication used in parallel programming and
object orientated programming.
Object
This is a self-contained entity that consists of both data and procedures to
manipulate the data.
Polymorphism
This is a programming languages ability to process objects differently depending
on their data type or class.
Procedure
This is a section of a program that performs a specific task.

Advantages of OOP

Code reuse and recycling: Objects created for OOP can easily be reused
in other programs.
Provides a clear structure: Provides a clear modular structure for
programs, this is good for defining abstract data types where
implementation details are hidden and the unit has a clearly defined
interface.
Provides a good framework: Provides a good framework for code
libraries wherein supplied software components can easily be adapted and
modified by the programmer.

What is a class and how to create class properties and class methods?
Using constructors
Constructors have one purpose and that is to create an instance of a class
What is an object?
An object can be a variable, a data structure or a function with a location in
memory and having a value and possibly referenced by an identifier. In OOP an
object refers to a particular instance of a class where the object can be a
combination of variables, functions or data structures.
Instance variables/member variables
Encapsulation
Once an object is created, knowledge of its implementation is not necessary for
its use. In older programs, coders needed to understand the details of a piece of
code before using it in this program or another. Objects also have the ability to
hide certain parts of themselves from programmers. This prevents programmers
from tampering with values they shouldnt. The object controls how one interacts
with it, preventing other kinds of errors.
Data abstraction
Data abstraction is the reduction of a particular body of data to a simplified
representation of the whole. It is usually the first step in database design as a
complete database can be much too complex to be developed without first
creating a simple framework. By using data abstraction you make it possible to
start from the essential elements.
Inheritance
In OOP inheritance is when an object or class is based on another object or class.
It is a mechanism for code reuse and to allow independent extensions of the
original software via public classes and interfaces.
There are various types of inheritance

Single inheritance where subclasses inherit the features of one superclass.


Multiple inheritance where one class can have more than one superclass
and inherit features from all parent classes.

Hierarchical inheritance is where one class serves as a superclass for more


than one sub class.
Hybrid inheritance is a mix of two or more of the above types of
inheritance.

Polymorphism
Polymorphism means to appear in many forms and in OOP this refers to the
programming languages ability to process objects differently depending on their
data type or class. Polymorphism allows the programmer to define different area
methods for any number of derived classes. It is also considered to be a
requirement of any true OOP language.
Abstraction and interfaces
Access modifiers
Access modifiers are keywords in OOP languages that set the accessibility of
classes, methods and other members. They are a specific part of programming
language syntax used to facilitate the encapsulation of components. Some
examples are: public, protected and private.
Overloading methods

S-ar putea să vă placă și