Salesforce Dev Notes - PDF - Constructor (Object Oriented Programming) - Programming
Salesforce Dev Notes - PDF - Constructor (Object Oriented Programming) - Programming
Download
Documents now Programming
Computers 2 of 25 Search document
Save 0% 100% Embed Share Print
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
Uncompiled Apex
Meta data
Internet
Request Apex Request
Apex Runme
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:
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);
}
}
SYNTAX:
Private: If a class is declared private it is only known to the block in which it is declared.
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) [override] [stac] data_type method_name (input parameters)
{
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 ();
E.g.:
Class Example
{
//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 ()
{
}
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
Document 77 pages
My C++
snathick
100% (1)
Document 8 pages
asp_oct_2013
Jainish Shah
No ratings yet
Document 31 pages
Document 10 pages
Document 18 pages
Question Bank
Parimala Vimal
No ratings yet
of 25
of 25
Related titles
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
Gifts
Language: English