Documente Academic
Documente Profesional
Documente Cultură
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
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