Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

Declarative Approach

80-90%(Point and Click) and 10-20%(logic)

Programmatic Approach
80-90%(Coding) and 10-20%(Point and Click)

What is a Software?
Software is a set of programs.

What is a Program?
Program is a set of instructions.

Programming Language is a language which is used to give instructions to computer.


Machine Language(0,1)-1940
01100101 11001100
Assembly Language
BPCL
B
C
C++
Java,Smalltalk,c#,F# etc
Apex Language

Tools:
Developer Console
Visual Studio Code

Variable:is a temporary storage location in the memory that has a name, has an
address, may contain a value and is always associated with a data type.

Data Type: specifies the type of data.

Sobject Data type: is used to store entire record(s).

Specific-Sobject can store records of specific type only.


Account acc;
Lead ld;
Contact con;

Generic- Sobject can store record of any type of object.

Sobject ob;

By default,classes runs in system context.

with Sharing is used to impose security.

By default, the variables and methods are private.

Access Modifiers:specifies the scope of a class member.

i)Private: private members are accessible only inside the class in which they are
defined.
ii)Protected: protected members are accessible inside the class in which they are
defined and by the child classes also.
iii)Public: public members are accessible in all the classes within Salesforce.
iv)Global:global members are accessible inside salesforce and outside salesforce
also.
Static Members:
-are the members that get memory at the compilation time.
-Static members are allocated memory once throughout the program.
-Static members maintain a single copy and that is shared by all the objects.
-'static' keyword is used to make a member static.
-static members are called by the class name using the dot notation.
-static methods can only use static variables.

Constant members:
-are the members that have fixed value or we can say that they are initialized once
at the time declaration or inside the constructors.
For ex: Pi,GST
-'final' keyword is used to make member constant.

Constructor:
-is a special method that has a same name as of class but preceded by parenthesis.
-do not have return types.
-are used to allocate memory to class.
-are called automatically whenever an instance of a class created.
-constructors can be used to initialize member variables and to call other methods.
-can be overloaded.

Properties:
-are members of a class that can be used to implement encapsulation.
-are composed of get and set accessors.
-set is used to store the value and get is used to return a value.

Interface:is a way to implement abstraction.


-in interface all the methods are abstract by default.
-all the methods of an interface needs to be defined in the class which is
implementing the interface.
-is a way to implement multiple inheritance.
-to define an interface 'interface' keyword is used.
-to use an interface 'implements' keyword is used.
-gives 100% of abstraction.

Interface-PurchaseOrder
Discount()

Employees

Customer

Constructs
i)Conditional Constructs: are used for making decisions
-if else
-check a number if its even or odd.
-if else ladder
-Units<100 then 2rs per unit
-units>100 and <200 then 3rs per unit
-units>200 and <300 then 4rs per unit
-nested if else
Age,Marks,Qual-Selected/rejected
-switch statement

ii)Looping Constructs: are used for iterations


Start-initialization
Stop- condition
Step- increment/decrement

-do while: is an exit controlled loop means condition is checked at the exit time
and hence, it will execute at least once even if the condition is false.
-while: is an entry controlled loop means condition is checked at the entry time.
-for: is a compact loop and is also an entry controlled loop.

-foreach: this loop is used when we are not aware of the size of a collection.

Array: is a collection of elements of similar data type.Storage in an array is


continous.
Start Index-0
last Index-size-1

5 schools
10 participants(name,score)
10*2*5=100 variables

School1Name[10],School1Score[10] * 5=10

Syntax:
integer [] Score=new integer [10];//declaration

Score[0]=89;//initialization
Score[1]=67;
Score[2]=78;

System.debug(Score[1]);

Apex Collections:
i)List:
-is a ordered collection of an elements.
-list can have duplicates.
-is best alternative to an array.
-some methods are: add(),size(),contains(),remove(), clear() etc.

Syntax:
List<data_type> Listname=new List<data_type>();

ii)Set:
-is an unordered collection of elements.
-set cannot have duplicates.
-some methods are:add(),contains(),size() etc.

Syntax:
Set<data_type> setName=new Set<data_type>();

iii)Map:
-stores the values in key-value pair.
-values can be duplicated but not the keys.
-some methods are: put(),get(),Values(),keyset(),putAll() etc
Syntax:
Map<data_type,data_type> MapName=new Map<data_type,data_type>();

You might also like