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.

Inheritance in Apex

Inheritance in Apex I nheritance in Apex is a mechanism by which one object acquires all the properties and behaviors of parent object. The idea behind inheritance in Apex is that you can create new classes that are built upon existing classes. Whenever you inherit from an existing class, you can reuse methods and fields of parent / super class, as well as you can add new methods and fields also based on the requirements. Reason to use inheritance : For Method Overriding (to achieved runtime polymorphism). For Code Reusability Various term used in inheritance : Class: A class is a concept/prototype/template of common properties, from which objects are created. Child Class/Sub Class: Child class is a class which inherits the other class, known as child class. It is also called extended class, derived class, or sub class. Parent Class/Super Class: Parent class is t...