OOPChapter 01
OOPChapter 01
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.
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.
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.
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.
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.
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.
A. Procedural Programming
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.
Below are some of the differences between procedural and 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.
Procedural programming uses the concept of Object-oriented programming uses the concept
procedure abstraction. of data abstraction.
Examples: C, FORTRAN, Pascal, Basic, etc. Examples: C++, Java, Python, C#, etc.