Apex allows Salesforce developers to customize and create out-of-the-box solutions. A Salesforce developer is an individual who excels in the development of standard and custom Salesforce solutions using Apex programming. Overall, Apex allows developers to execute process flows and transaction control statements while witnessing API calls. In addition, it enables Salesforce customers to add custom functionalities to their reliable applications.
What Is Apex?
Apex is an object-oriented programming language and a proprietary language developed by Salesforce. It is a strongly-typed language. Moreover, it is effortless for strongly-typed languages to predict the nature of the behaviour of the written code. At first, Apex language allows you to write custom code examples and robust solutions executed on the Force.com platform. You can quickly build SaaS applications on top of Salesforce with the help of Apex. It enables the Salesforce developer to add custom business logic to several events, including button on-clicks, current and related record updates, and triggering visual Force and Lightning pages.
Example (Date)
2. sObject
sObjects are very interesting kind, they store the records of any particular salesforce objects. However, we just need to specify the object name as the data type.
Example (sObject)
Thereafter, try this out in the developer console and the output is:
3. A collection
A collections is a type of variable which can store multiple data. In salesforce we generally use this to store multiple records. They are of three types list, set and map.
i) List
Firstly, a list stores multiple data with an ordered index starting from 0 and repeated values are allowed. Let’s take a simple example of lists.
For example:
ii) Set
A set stores multiple data with an unordered index and unique values are allowed. Let’s take a simple example of sets.
For example:
iii) Maps
In detail maps are different. It stores the multiple data of key and value pairs. Here each value has a unique key. Both can be of any data types.
For instance:
4. Enums
In simple Enums are user defined data types. Developers can also store predefined values in that data type. Now when you try to store any other value in that variable it shows error.
Example:
Now after creating this class, developers can declare any variable with this “week” data type and the values assigning to them should only be one of these “SUN, MON, TUE, WED, THUR, FRI, SAT” like, week x = week.SUN;
5. Classes
A class is a blueprint for an object which consists of all the methods and variables. Apex classes are similar to java classes.
In order to create a class in Force.com
- pen developer console
- click file
- thirdly, click new
- click Apex class
- Enter the name of the class
- click OK,
6. Objects
Objects are the instance of a class in simple. In salesforce we can also create objects of sObjects which is simple.
7. Interfaces
An Interface is similar to class but the difference is in class developers provide the methods body but in Interface we provide only method names but not body we have to implement them to our classes and then we have to write the method body.
8. Null
Null is a reserved word in apex. When you create a variable without initializing anything to it then the variable stores null. Also when you initialize the value with a word null then also the variable stores null. However “stores null” means stores nothing or empty.
For More Blogs: Click Here