Apex Non Developers Flashcards
Attributes
Which describe properties (nouns or adjectives). They are characteristics of the class
access modifier, data type, unique name
public String name;
public String height;
Methods
Which describe behavior (verbs)
Actions performed by a class
Methods of the human class
Walk, Talk, work
Attributes of the human class
Toes, Fingers, Hands, Name
Instantiation
Creating an object from a class
Instantiation requires?
class name,
object name,
new keyword,
class name with parentheses
Method declaration syntax includes
An access modifier, a data type or void, a unique method name, a pair of parentheses, a code block with curly braces
public void walk(){
}
Attribute declaration syntax includes
An access modifier, a data type, a unique name
A Method can either return?
1) Void or
2) A single data type: which could be a collection
- -Use the return keyword to pass back a value
Primitives
basic building blocks and cannot be broken down
String firstname = ‘Adam’;
Composites
Non-primitive data types that are built from other data types. Often see the keyword new.
Human man1 = new Human(); Human woman1 - new Human();
A Method can either return?
Void or
A single data type: which could be a collection
–Use the return keyword to pass back a value
When you see a composite being declared what do you usually see?
the keyword new
How do you pass in parameters to a method
You can pass attributes as parameters into a method inside of the ()
The method declaration must supply:
1)a data type that indicates what type of data the method should expect
2)a local variable name that will accept the incoming data
Instantiate an object from the BankAcct class called chkAcct
chkAcct BankAcct = new chkAcct();
Set the attribute accttype of the object chkAcct to Checking
chkAcct.accttype = ‘Checking’;
Set the attribute acctName of the object chkAcct to D.Castillo-Chk
chkAcct.acctName = ‘D.Castillo-Chk’
Invoke the makeDeposit method for $150
chkAcct.makeDeposit(150);
What is a list?
An ordered collection of data of one data type distinguished by its index
Each element in a list contains what 2 pieces of information
An index: an integer that always starts at 0
A value: The data
Whenever you’re looking at a parentheses you’re looking at
A Method
Declare a method that does not return anything and takes one input parameter of a Candidate list object called candsFromTrigger
public void createContact (List candsFromTrigger){
What does the List for loop do?
It iterates over all of the elements in a list one by one with the help of an iteration variable
What is an sObject?
standard or custom objects that store record data in the force.com database
How do developers refer to sObjects and fields
By API names
An sObject variable represents
a row of data and can only be declared in Apex using the SOAP API name of the object
Instantiate an sObject
Account a = new Account();
DML Operations
saving changes to records in the database Insert Update Upsert Delete
DML can operate on?
A single sObject or a list of sObject
Database.insert
Database is the class. .insert is the method
Instantiate an object called acct from the sObject Account class
Account acct = new Account();
Set the attribute name of the acct object to Recruiting
acct.name=’Recruiting’;
Instantiate an object called heese from the sObject Account class
Account heese = new Account();
SOQL
Salesforce Object Query Language