What is Apex programming language?
Apex is a very strongly typed object-oriented, on-demand programming language. It is compiled, stored, and run entirely on the Force.com platform (multi-tenant environment and is very controlled in its invocations and limits as it’s running on cloud).
Note : It’s a case insensitive language.
- Apex syntax looks mostly like a Java programming language.
- Apex allows developers to write business logic to the record save process.
- Apex has built in support for unit test creation and its execution.
Apex provided build in support for followings:
- Data Manipulation language(DML) calls to insert, update, and delete record.
- Inline SOSL or SOQL statements for retrieving records from sObjects.
- Looping control structures that help with bulky processing.
- A record locking syntax that prevents records being conflicts.
- Custom public API calls.
- Send and receive an email.
- Web services(REST/SOAP) request/response integrations.
- Warnings and errors to prevent sObjects referenced by Apex from being modified.
As a language apex is Integrated, Very easy to use, Data focused, Rigorous, Hosted, Multi-Tenant aware, automatically upgradable in nature, easy to test and versioned.
When developers write & save their code in a platform, which is compiled on force.com platform and stored in the form of metadata in Salesforce servers then end users can send requests from UI & retrieve results from Salesforce servers.
Below are few capabilities of Apex
When we can use Apex programming?
Apex should be used as a solution when:
- You need to write complex business logic to rows of data being saved by any means.
- You need to create additional web services API functionality for exposing logic either within Salesforce or to outside of Salesforce.
- You need to call out to an external Web service and process the results.
- You need to manage incoming or outgoing emails in ways more complex than the declarative functionality.
- Apex triggers execute no matter how the triggering data is being saved.
- Apex executes regardless of whether the action originates in the user interface, through AJAX toolkit, or from web services API.
- If you only want the code to execute through UI, consider making a visualforce page and controller.
Difference b/w traditional programming & Apex programming
Traditional code is fully flexible, and can tell the system to do anything as per the requirement.
Apex is a governed language, can only do what the system allows.