Apex Fundamentals
Apex is a Object Oriented, On-demand programming language.like java and other OOP languages.
Apex runs in multi-tenant environment,It means the environment is shared with several such type of tenants who are using like us so to avoid the monopoly of resources like storage and CPU by any tenant the most important thing called "Governors rules" works here.
Governors rules are the limits set by Apex Run-time Engine,It monitors all transactions and usages of resources available on multi tenant environment and enforces every transaction to stay in limits specified by the Salesforce.
Apex is in-sensitive and compiled and execute on cloud.It is not a general purpose programming language, its a proprietary language of Salesforce.It requires unit testing with data coverage more than 75% for deployment, so for testing Ape have Test classes to write with every functionality we develop in Apex.
Apex code can be saved as one of the below two types:
1)Class
2)Triggers
Apex Class: is a collection of attributes and methods that instantiated into a Object same as any other Object Oriented Programming language class has.
e.g:
Integer i = 5;
Account[] acc;
//Clean data
acc = [SELECT Id FROM Account WHERE name LIKE 'test%' ];
Delete acc;
//Insert daa
acc = new Account[i];
for (Integer j = 0; j <= i; j++)
{
acc[j] = new Account(nsme='test '+j);
}
Insert acc;
Triggers: Is a piece of Apex code that executed before or after a specific Data Manipulation Language(DML) event on a particular Salesforce object.
Syntax: trigger trigger_name On ObjectName(trigger_events)
{
code_block;
}
trigger_events are :
1)Before : Insert,Update,Delete.
before insert
before update
before delete
1)After : Insert,Update,Delete,undelete.
after insert
after update
after delete
after undelete
0 Comments