Apex · Salesforce

APEX ORIENTED OOPS (OBJECT ORIENTED PROGRAMMING)

Before going to do coding in apex once recall the basics of object oriented programming (OOP) language concepts.

What is OOPs :-

OOP (Object Oriented Programming) is a methodology, that provides a way of modularizing a program by creating partitioned memory areas for both data and methods that can be used as templates for creating copies of such objects (Models) on demand.

Unlike procedural language, here in oops programming language programs are organized around objects and data rather than action and logic.

The main OOPs Principles used in apex Language are,  

  • Object
  • Class
  • Inheritance 
  • Polymorphism    
  • Abstraction
  • Encapsulation

Object:-  

In this real word Any entity that has state and behavior is known as an object.  It can be physical and logical.  

Example: Book, Ball, Spoon, Van, water Bottle, etc.


Class :- 

Class is a Collection of objects. It is a logical entity.

Example: The animal is class and Animal types are objects. There are many objects in a class.

Inheritance :

When one object acquires all the properties and behavior of parent object i.e. known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism.

Example: Parents producing the children inheriting qualities of the parents.

Polymorphism:- 

When one task is performed by different ways simply it’s called as polymorphism. we use method overloading and method overriding to achieve polymorphism.

Example: We want to go from one place to another place in the vehicle but the vehicle type is different.

Abstraction:- 

Hiding internal details and showing functionality is known as abstraction. we use abstract class and interface to achieve abstraction.

Encapsulation:-

Binding (or wrapping) code and data together into a single unit is known as encapsulation.

Example: ATM machines, we don’t know the inside ATM.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s