Skip to main content

OOP,s Concepts in APEX

What is OOP's Concepts in APEX Programming ?

 

  • Object-Oriented Programming System (OOPs) is a programming concept that works on the principles of abstraction, encapsulation, inheritance, and polymorphism. It allows users to create objects they want and create methods to handle those objects. The basic concept of OOPs is to create objects, re-use them throughout the program, and manipulate these objects to get results.
  • OOP meaning “Object Oriented Programming” is a popularly known and widely used concept in modern programming languages like Java, Apex and many other.

List of OOP's Concepts

Class : The class is one of the Basic concepts of OOPs which is a group of similar entities. It is only a logical component and not the physical entity. Lets understand this one of the OOPs Concepts with example, if you had a class called “Expensive Cars” it could have objects like Mercedes, BMW, Toyota, etc. Its properties(data) can be price or speed of these cars. While the methods may be performed with these cars are driving, reverse, braking etc.

Object : An object can be defined as an instance of a class, and there can be multiple instances of a class in a program. An Object is one of the Apex OOPs concepts which contains both the data and the function, which operates on the data. For example – chair, bike, marker, pen, table, car, etc.

> Inheritance : Inheritance is one of the Basic Concepts of OOPs in which one object acquires the properties and behaviors of the parent object. It’s creating a parent-child relationship between two classes. It offers robust and natural mechanism for organizing and structure of any software.

Polymorphism : Polymorphism refers to one of the OOPs concepts in Apex which is the ability of a variable, object or function to take on multiple forms. For example, in English, the verb run has a different meaning if you use it with a laptop, a foot race, and business. Here, we understand the meaning of run based on the other words used along with it. The same also applied to Polymorphism.

Encapsulation : Encapsulation is one of the best Apex OOPs concepts of wrapping the data and code. In this OOPs concept, the variables of a class are always hidden from other classes. It can only be accessed using the methods of their current class. For example – in school, a student cannot exist without a class.

Abstraction : Hiding internal complexity and showing functionality is known as abstraction. For example: Car Drive, we don’t know the internal processing. It is also used to provide the set of guidelines for development. In apex, we use abstract class and interface to achieve the abstraction.


Advantages of OOP's Programming

  1. OOPs Concepts in Java offer easy to understand and a clear modular structure for programs.
  2. Objects created for Object-Oriented Programs can be reused in other programs. Thus it saves significant development cost.
  3. Large programs are difficult to write, but if the development and designing team follow OOPS concepts, then they can better design with minimum flaws.
  4. It enhances program modularity because every object exists independently.


By : Harshal Lad 

Comments

Popular posts from this blog

Apex Triggers and Classes

  Apex Triggers   is use to execute the functionality or piece of code on record manipulation ( i.e., CREATE / UPDATE / DELETE / UNDELETE   records ). A trigger executes before and after an event occurs on record.

Polymorphism in Apex

Polymorphism in Apex P olymorphism in simple word can be said as  One name many forms. For example , a man can play a role as an Employee, as a Father or as a Husband in his day-to-day life. It means that he can be in any of these form.  Polymorphism can be achieved by these two ways : Method Overloading Method Overriding Method Overloading If a class have multiple methods with same name but different parameters (either different length of the arguments or different data types of the arguments), it is known as Method Overloading. If we have to perform only one operation, with the same name of the methods increases the readability of the program as well as its very logical too. Let’s suppose if we want to perform addition of the given numbers but there can be any number in arguments as below: Example of method over...