Search Read free for 30 days
Download
Documents now Programming
Computers 2 of 25 Search document
0% (2) · 1K views · 25 pages
Salesforce Dev Notes
Uploaded by Vasu Vasu on Jan 30, 2021
Salesforce devleoper practise notes Full description
Save 0% 100% Embed Share Print
Download now 2 of 25 Search document
Salesforce Development:
-----------------------------------------------
APEX:
Apex is a strongly typed object-oriented programming language.
It allows the developers to execute ows and transacon control statements
Apex enables developers to add business logic
When should I use Apex:
To create email service
Create webservices
Perform complex validaon over mulple objects
To create complex business processes that are not supported by workow
Create custom transacon logic
Aach custom logic to another operaon
How does apex work:
All apex programs run enrely on-demand on force.com plaorm
Developer Force.com Plaorm
Uncompiled Apex
App Server Compiled Apex
Meta data
Internet
Request Apex Request
Apex Runme
Result Compiled Apex
End User
First, app server compiles the code into set of instrucons that can be understood by the runme
interpreter.
The complete code is stored to meta data.
When the end user triggers the execuon of apex by clicking the buon or VF page, the app server
retrieves the compiled instrucons from the metadata and send them to run me interpreter before
returning the result.
OOPS:
In oops, programs are organized around objects and data rather than logic and acons.
OOPS is a methodology that provides a way of modularizing a program by creang paroned
memory area for both data and methods that can be used as template for creang copies of such
modules(objects) on demand
The main oops principles are:
1.Encapsulaon
2.Inheritance
3.Polymorphism
1.Encapsulaon: The wrapping up of data and methods together is called encapsulaon.
2.Inheritance: It creates new classes from exisng classes, so that the new classes will acquire all the
features of the exisng classes.
3.Polymorphism: It represents one form in mulple forms
------------------------------------------------------
Apex Fundamentals:
of 25 type of data can be stored.
Data types: Data types in apex tells about what
There are 3 types:
i)Primive data types
ii)Collecons
iii) Enums
i)Primive data types: These are the data types which are predened by the apex.
All primive data types are passed by value, not by reference
Apex primive data types include:
Boolean Date Time Dateme
Integer Long Double Decimal
#All Apex variables are inialized to null.
Sobjects:
Sobjects are short for “Salesforce Objects”.
An Sobject can be generic sobject or be a specic sobjects such as Account,Contact or
MyCustomer__c.
Sobjects are standard or custom objects that stores record data in the force.com database.
Developers refer to sobjects and their elds by their API Names.
Class: Class is a collecon of data members and methods.
Eg:
Class student
{
Integer no; Data members of class
String name;
Public void getdetails ()
{
System. Debug (‘Roll no’ +no); Method of class
System. Debug (‘Name’ +name);
}
}
How to dene an apex class specify the following:
i)Access Modiers:
-We must use one of the access modiers for top level class (public or global).
-We should not have to use access modiers in the declaraon of inner classes.
ii)Oponal denion modiers such as virtual and abstract
iii)Required are the keyword ‘Class’ followed by class name
iv)Oponal extensions include AND/OR implementaons.
SYNTAX:
Private|public|global [virtual|abstract|with sharing|(none)] class className [implements
interfaceNameList|(none)] [extends className|(none)]
{
The body of the class
}
Access Modifers:
Private: If a class is declared private it is only known to the block in which it is declared.
###### By default, all the inner classes are private.
Public: If a class is declared public, it is visible throughout the applicaon and you can access the app.
Anywhere.
of 25
Global: If a class is declared global, this apex class is visible to all the apex applicaons in the applicaon or
outside the applicaon.
###### If the method or inner class is declared a s global then the top-level class also must be declared as
global.
With Sharing: If the class is declared as a with sharing, sharing rules given to the current user will be taken
into the consideraon and the user can access and perform the operaons based on the permissions given
to him on objects and elds (eld level security, sharing rules).
Without sharing: If a class is declared as a without sharing then this apex class runs in system mode which
means apex code has access to all the objects and elds irrespecve of current users sharing rule, eld
level security, object permissions.
Points to be noted:
-If a class is not declared as with sharing or without sharing then by default the class is executed in system
mode i.e., without sharing.
-Both inner classes and outer classes can be declared as with sharing
-If the inner class is with sharing and top-level class is without sharing then by default enre context will
run in with sharing context.
- If a class in not declared as with/without sharing and if this class is called by another class in which
sharing is enforced then both the classes run with ‘with sharing’.
-If outer class is with sharing and inner class is without sharing then the enre class runs in without sharing
context only.
##Inner classes don’t take the sharing properes from outer class
-Virtual: If a class is declared with keyword- virtual then this class can be extended (Inherited) or this class
methods can be overridden by using a class called overridden
-Abstract: This class contains abstract methods
Class Variables: The variables in the class should specify the following properes when they are dened.
i)Oponal: modiers such as public or nal or stac
ii)Required: the data types of the variable
iii)Required: the value of the variable
iv)oponal: the name of the variable
SYNTAX: [public|private|protected|global|nal] [stac] data_type variable_name
E.g.
Private stac nal Integer My_Int;
Private nal integer i=1;
Class Methods: To dene the methods specify the following
i)Oponal: Modiers such as public or protected
ii)Required: The data type of the value returned by the method such as string or integer. Use void if no
value is returned.
iii)Required: a list of input parameters for the method separated by commas, each preceded by its data
type and enclosed in parentheses (). If no parameters use a set of empty parentheses.
##A method can only have 32 input parameters
iv)Required: The body of the method, enclosed in braces {}. All the code for the method including any local
variable declaraons is contained here.
SYNTAX:
(public|private|protected|global) [override] [stac] data_type method_name (input parameters)
{
//body of the method
}
of 25
E.g.
Public stac integer getInt ()
{
Return my_Int;
}
E.g.
Public class example
{
Public integer show (Integer age)
{
System. Debug(‘My age is ’ +age);
}
}
Object: Object is an instance of the class. This has both state and behavior.
#Memory for the data members are allocated only when an object is created.
SYNTAX:
ClassName objectname = new ClassName ();
Name of the Keyword which
class for which It is a reference we are
we are creang variable allocang the Constructor
an object memory
E.g.:
Class Example
{
//code
}
Example e = new Example ();
Constructor: Constructor is a special method which have the following properes
i) Method name will be the same as the class name
ii) Access speciers will be public
iii) This method will be invoked once only at the me of object creaon
iv) This is used to instanate the data members of the class
E.g.:
Public class TestObject
{
//The no argument constructor
Public TestObject ()
{
//code
}
}
of 25
There are 3 types of constructors…
1)Default constructor
2)Non parameterized constructor
3) Parameterized Constructor
1)Default Constructor:
Is an apex class does not contain any constructor then apex compiler by default creates a
dummy constructor on the name of the class when we create an object for the class.
E.g:
Public class Example
{
}
Example e = new Example ();
In the above example the apex class does not contain any constructor. So when we create object
for Example class the apex compiler creates a default constructor as…
Public example ()
{
}
2)Non parameterized constructor and parameterized constructor:
It is a constructor that doesn’t have any parameters or constructor that has parameters.
E.g.:
Public class Example
{
Integer rno;
String name;
Public Example (Integer x, string myname)
{
rno = x; parameterized
name = myname;
}
Public Example ()
{
//code
rno = 10; Non-parameterized
name = vasu;
}
}
Usage of Apex program in visual force page:
1) When we want to call Apex class in VF page, we have to declare in the following format.
<Apex: page controller = “classname”>
Whenever we call a vf page in which controller aribute is dened
It will rst create an object for the apex class which is dened in controller.
2) When object is created for the apex class rst it invokes the constructor.
Referring to the apex class members in VF:
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
of 25
Reward Your Curiosity
Everything you want to read.
Anytime. Anywhere. Any device.
Read free for 30 days
No Commitment. Cancel anytime.
Share this document
You might also like
of 25
Ebook 221 pages
Hibernate, Spring & Struts Interview Questions You'll Most Likely Be Asked
Vibrant Publishers
No ratings yet
Document 22 pages
DOC-20190813-WA0088.docx
Shifanila
No ratings yet
Document 23 pages
Tutorial
Golf Romeo
No ratings yet
Document 47 pages
C Sharp Objects
Sai Praveen
No ratings yet
Document 10 pages
OOPS Long
abc ker
No ratings yet
Document 19 pages
Day 2 Oops Concepts
Pradeepthi Bonthala
No ratings yet
Document 38 pages
of 25
Lecture-1_CSE-225 Tamanna Motahar NSU
Md. Al-Amin Ahmed 1712249630
No ratings yet
Document 77 pages
My C++
snathick
100% (1)
Document 8 pages
asp_oct_2013
Jainish Shah
No ratings yet
Document 31 pages
C++ COMPREHENSIVE VIVA
aj
No ratings yet
Document 10 pages
Top 50 C# Interview Questions and Answers (1)
Romil
No ratings yet
Document 18 pages
Question Bank
Parimala Vimal
No ratings yet
of 25
of 25
Related titles
Ebook Document Document Document Document Document Docu
Hibernate, Spring DOC-20190813- Tutorial C Sharp Objects OOPS Long Day 2 Oops Lec
& Struts Intervi… WA0088.docx Added by Golf Romeo Added by Sai Praveen Added by abc ker Concepts 225
Vibrant Publishers Added by Shifanila Added by Pradeepth… Add
0 ratings 0 ratings 0 ratings 0 ratings 0 ratings 0
0 ratings
About Support Legal Social
About Scribd Help / FAQ Terms Instagram
Press Accessibility Privacy Twitter
Our blog Purchase help Copyright Facebook
Join our team! AdChoices Cookie Preferences Pinterest
Contact us Publishers Do not sell or share my
personal information
Invite friends
Gifts
Scribd for enterprise
Get our free apps
Audiobooks • Books • Documents • Magazines • Podcasts • Sheet music • Snapshots
Language: English
Copyright © 2023 Scribd Inc.