Upload
priyapanigrahy
View
931
Download
3
Embed Size (px)
DESCRIPTION
Citation preview
Apex Language Construct
Study GuideStudy Guide
Presenting By:Presenting By:Abhijita PanigrahyAbhijita Panigrahy
TrainerTrainerCeptes Software Pvt. Ltd.Ceptes Software Pvt. Ltd.Email: Email: [email protected]
Content
What is Apex Language Construct Testing Apex
What is Apex
Force.com Apex code is a strongly-typed, object-oriented programming language that allows developers to execute flow and
transaction control statements on the Force.com platform server in conjunction with calls to the Force.com API.
All Apex runs entirely on-demand on the Force.com platform, as shown in the following architecture diagram:
Supports
Data manipulation language (DML) Inline Salesforce.com Object Query Language (SOQL) and
Salesforce.com Object Search Language (SOSL) queries that return lists of sObject records
Looping Locking syntax Custom public Force.com API calls etc.
When Should I Use Apex
Create Web services Create email services Perform complex validation over multiple objects Create complex business processes that are not supported by
workflow Create custom transactional Attach custom logic to another operation, such as saving a record
Limitations of Apex
Render elements in the user interface other than error messages Change standard functionality—Apex can only prevent the
functionality from happening, or add additional functionality Create temporary files Spawn threads
Apex cannot be used to:
Understanding Apex Core Concepts
A typical Apex script contains many things that you might be familiar withfrom other programming languages:
Writing Your First Apex Script
To create a apex class click Setup Develop Apex Classes, click New➤ ➤
Testing Apex Script
Testing and unit tests are an important part of the development. You must have at least 75% of your Apex scripts covered by unit tests to deploy your scripts to production environments. In addition, all triggers should have some test coverage. Salesforce.com recommends that you have 100% of your scripts covered by unit tests, where possible. Calls to System.debug are not counted as part of Apex code coverage in unit tests.
@isTest private class TestClassName{static testMethod void methodName() {}}
Language Constructs
Data Types Variables Expressions Assignment Statements Conditional Statements Loops Exception Statements
Data Types
Decimal Double ID Integer Long String Time sObject Types (eg: Account a = new Account();
MyCustomObject__c co = new MyCustomObject__c();)
Collections
Lists Maps Sets
List
The following are ways to declare and populate a set:
Set & Map
The following are ways to declare and populate a set or a map:
Variables
Case Sensitivity Constants
eg : static final IntegerPRIVATE_INT_CONST;
static final IntegerPRIVATE_INT_CONST2 = 200;
Loops
Do-While Loops While Loops For Loops Traditional For Loops
Exception Statements
Throw Statements Try-Catch-Finally Statements
throw statements can be used to generate exceptions, while
try, catch, and finally can be used to gracefully recover from
an exception.