Menu Bar

Monday 27 August 2012

Core Concepts of APEX


Using Variables and Expressions

Declare the data type of a variable when you first refer to it. Apex data types include basic types such as Integer, Date, and Boolean, as well as more advanced types such as lists, maps, objects and sObjects.
datatypevariable_name [ = value];

Eg:   int count = 0;

Decimal total;
// The following variable is an account, which is also referred to as an sObject.
Account MyAcct =
new Account();

REF: http://shivasoft.in/blog/java/pass-by-value-and-pass-by-reference/

Using Statements

Statement is any coded instruction that performs an action.

Types of APEX Statements
Assignment
Conditional
Loops
for
while
do while
Locking
DML
Transaction Control
Method Invoking
Exception Handling

Using Collections

Types of Collections

Lists(Arrays) : A list is a collection of elements, such as Integers, Strings, objects, or other collections.
Maps
Sets

A  LIST is a collection of elements, such as Integers, Strings, objects, or other collections. Use a list when the sequence of elements is important. You can have duplicate elements in a list.
Set<datatype> set_name
  [=
new Set<datatype>();] |
  [=
new Set<datatype>{value [, value2. . .] };] |
  ;

Eg:  
List<Integer> My_List = new List<Integer>();



A SET  is a collection of unique, unordered elements. It can contain primitive data types, such as String, Integer, Date, and so on. It can also contain more complex data types, such as sObjects.

Set<datatype> set_name
  [=
new Set<datatype>();] |
  [=
new Set<datatype>{value [, value2. . .] };] |
  ;
Eg:
set<string> My_string = new set<string>{“a”,”b”,”c”,”d”};

http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_sets.htm


A  MAP is a collection of key-value pairs. Keys can be any primitive data type. Values can include primitive data types, as well as objects and other collections. Use a map when finding something by key matters. You can have duplicate values in a map, but each key must be unique.

Map<key_datatype, value_datatype> map_name
  [=
new map<key_datatype, value_datatype>();] |
  [=
new map<key_datatype, value_datatype>
  {
key1_value => value1_value
  [,
key2_value => value2_value. . .]};] |
  ;
Eg:
Map<integer,string>My_Map = new Map<integer,string>{1=>’a’,2=>’b’,3=>’c’,4=>’d’};

http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_maps.htm

Using Branching

http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_if_else.htm

Using Loops


http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_loops.htm

2 comments:

Anonymous said...

http://www.youtube.com/watch?v=xJH8gyKwN70&feature=relmfu

Anonymous said...

http://www.youtube.com/watch?v=1e6aKUzniPM&feature=relmfu