17
Apex Language Construct Study Study Guide Guide Presenting By: Presenting By: Abhijita Panigrahy Abhijita Panigrahy Trainer Trainer Ceptes Software Pvt. Ltd. Ceptes Software Pvt. Ltd. Email: Email: [email protected]

My cool new Slideshow!

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: My cool new Slideshow!

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]

Page 2: My cool new Slideshow!

Content

What is Apex Language Construct Testing Apex

Page 3: My cool new Slideshow!

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:

Page 4: My cool new Slideshow!

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.

Page 5: My cool new Slideshow!

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

Page 6: My cool new Slideshow!

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:

Page 7: My cool new Slideshow!

Understanding Apex Core Concepts

A typical Apex script contains many things that you might be familiar withfrom other programming languages:

Page 8: My cool new Slideshow!

Writing Your First Apex Script

To create a apex class click Setup Develop Apex Classes, click New➤ ➤

Page 9: My cool new Slideshow!

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() {}}

Page 10: My cool new Slideshow!

Language Constructs

Data Types Variables Expressions Assignment Statements Conditional Statements Loops Exception Statements

Page 11: My cool new Slideshow!

Data Types

Decimal Double ID Integer Long String Time sObject Types (eg: Account a = new Account();

MyCustomObject__c co = new MyCustomObject__c();)

Page 12: My cool new Slideshow!

Collections

Lists Maps Sets

Page 13: My cool new Slideshow!

List

The following are ways to declare and populate a set:

Page 14: My cool new Slideshow!

Set & Map

The following are ways to declare and populate a set or a map:

Page 15: My cool new Slideshow!

Variables

Case Sensitivity Constants

eg : static final IntegerPRIVATE_INT_CONST;

static final IntegerPRIVATE_INT_CONST2 = 200;

Page 16: My cool new Slideshow!

Loops

Do-While Loops While Loops For Loops Traditional For Loops

Page 17: My cool new Slideshow!

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.