Salesforce Basic

Apex Programming Language in Salesforce

Every technology has some or other programming language. There are well know programming languages namely, C, C++, Java, DotNet, Python, Javascript and many more. Object Oriented Programming Language (OOPS) is a concept on which most of the languages work. Similarly, Salesforce has its own programming language and it is called Apex Programming language.

Apex Programming language

Apex Programming language is strongly typed and works on OOPS concept. It uses similar syntax that looks like Java and acts like database stored procedures. Apex enables developers to add business logic to most of the system events which include button click, page load, related record update etc.


Apex language is

  • Integrated
  • Easy to use
  • Data focused
  • Rigorous
  • Hosted
  • Mutilated aware
  • Easy to test
  • Versioned

Integrated

  • Apex provides built in support for DML operations, including the exceptions
  • Support SOQL and SOSL statements
  • Loops operations to support bulk data
  • Locking syntax to prevent from update conflict.
  • Can build custom API from sored Apex methods
  • Warning or error messages when a object or field which is used in Apex getting deleted.

Easy to Use

  • Apex is like Java programming language.
  • Uses Variable declaration syntax, expression syntax, loop syntax, object and arrays that are similar to Java.
  • Apex adds new elements, all have easy to understand syntax.
  • Easy to write
  • Follow OOPS concept

Data Focused

  • Can handle multiple queries and DML operations in a single transaction.
  • Developers use database stored procedures to thread together multiple transaction statements on a database server
  • Apex does not attempt to provide general support for rendering elements in the user interface.

Rigorous

  • Apex is strongly typed language that uses direct reference to object or field names.
  • Fails to compile if references are invalid
  • All custom objects, fields and classes are stored in metadata so that they do not get deleted if there is any reference linking between them.

Hosted

Apex is interpreted, executed, and controlled entirely by the Lightning Platform.

Multitenant aware

  • As salesforce architecture is built on multitenancy, so is apex.
  • To avoid monopolizing of resources, there are governor limits set on apex language as well.
  • Limitation are set to the apex code size, method size, characters, file size of apex etc.
  • Limitations are set for the code that is written in the apex and proper exceptions are also written.

Easy to test

  • Provide built in support for unit test creating and execution
  • Support include, test results that indicate how much code is covered, which part id more effective.

Versioned

You can save your Apex code against different versions of the API.

know more about different data types and variables that are supported in Apex


How does it work?

How apex code words from both developer and end user

As you can see, When a developer writes an apex code, Application Server compiles the code. Once the code is understandable by the apex interpreter then the code can be saved as metadata.

When end users trigger a request to perform some operation in apex, the application server retrieves the compiled apex code from metadata and sends them through runtime interpreter before returning the result.


Resources.

Salesforce – What is apex?

Salesforce – How does it work?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s