ADM231 Flashcards
Apex is
a cloud based, object oriented programming language
Classes
Blueprints used for creating objects
Objects
Code is divided into objects that do work
Attributes
Characteristics of a class
Methods
The things that a class can do
Way to invoke apex
save, sending an email, anon blocks, web services, scheduled job, vf page
What is an sObject
A salesforce object
What does the Metadata API allow
access to salesforce metadata
Two characteristics of the metadata API
View metadata using the force.com ide and create modify metadata by writing apex code
What is metadata
refers to data that describes data. Custom object definitionss, page layouts, for your org
Force.com platform metadata can be described as>
XML
How does the force.com ide interact with the force.com platform?
Metadata API
What allows you to view the metadata and data for your org
The Schema Explorer
Anonymous blocks
are discrete sections of code run out of context
Anonymous blocks is a good way to
Test sections of code
System.debug()
a special method of the system class that you can add to your code to generate output when code is executed to provide feedback
Is system.debug() considered testing?
No
Pascal Case
When first letter of each word is in uppercase
Camel Case
When first letter of the first word is in lowercase and subsequent words are capitalized
Is Apex case sensititive?
No
Attribute names are typically written how
nouns and start with a lowercase letter
Constants are written?
All Capitalized and sometimes with an underscore
Methods use what case
Camel case. are typically verbs and followed by ()
Classes always start with?
Uppercase letter and followed by curly braces
What is syntax
Rules that describe how code should be structured
Dot notation refers to
The syntax of identifying and chaining together attributes or methods in OOP
Dot notation example
dog. age = 15
dog. bark();
Whats a statement
A single line of code terminated by a semicolon
What’s a block
INcludes multiple statements enclosed between curly braces
Methods require what to enclose statement parameters
( )
What must be used to enclose a string
Single quotes
Where do you open curly braces
on the line above the block
Two types of commenting
// AND /* */
Whats an operator
A symbol that performs an action on one or more arguments to product a result
3 types of operators
Math, logical, and comparsion
++
Increment by 1
–
Decrement by 1
Read a single equal sign as
is assigned the value of
Read double equal sign as
is equal to the value of
&& Logical AND
TRUE && TRUE = TRUE
|| Logical OR
TRUE || FALSE = TRUE
! Logical NOT
TRUE && !FALSE = TRUE
Expression
a statement made up of variables and operators resulting in a single value
If statements
allow you to execute code if a particular condition is met
if-Then Example
if (bell.isRinging == true){
spot.bark();
}
If-Then-else Example
if (bell.isRinging == true){ spot.bark(); } else { spot.rest(); }
Else-if Example
if(cmd.type == 'speak'){ spot.bark(); } else if (cmd.type == 'stay'){ spot.rest(); }
Whats a loop
A loop is used to run a block of code several times
Apex loop statments include
For Loops, While Loops, Do-While Loops
For looks are typically used when
the number of iterations is defined prior to entering the loop
Apex supports three types of for loops
Tradtional for loops, list or set iteration for loops, SOQL for loops
Traditional for loops contain how many statements
3
When is the condition checked in the do-while loop
not until AFTER the first pass is executed
When is the condition checked in the while loop
before the first pass
A nest loop is?
A loop that occurs within another loop. Think ODOMETER
How are methods named?
camel case
Primitives
Basic building blocks that are built into a language and cannot be broken down
Composites
Non-primitive data types that are built from other data types
Composites are
collections of primitives
Null
The absence of any value. A placeholder signifying that no value exists
Is null different from zero or an empty string
Yes
Variables are created with what initial value
NULL unless they are initialized
Null Pointer Exception
A program referenced something without a value
Declare a primitive with an initialized value
Boolean dogAwake = false; | Primitive datatype variable name
Declare a primitive variable without a value
Boolean dogAwake;
Primitive Numeric data types
Integer, Long, Double, Decimal
Primitive Calendar Data
Date, Time, DateTime
What’s a string?
Text data that can be any sequence of characters
How do you used reserved characters in strings
Precede them using a backslash \
String petstore = ‘Marc\s Pet World’
What’s an enum
Is an enumerated list, similar to a picklist, where one must choose from a pre-defined site of values
How do you declare an enum
Enum PetType {Dog, Cat, Fish, Bird}
What is a blob
A blob is used to store data as a collection of binary data
What is an ID
It’s a special primitive data type unique to the force.com Platform
Is the 15-char ID case sensitive
Yes
Is the 18-char ID case sensitive
NO
What is a composite data type
Any data type that is not a primitive data type
In Apex, composite data types include
sObjects, Collection data types, User or System Supplied Apex Classes
Composite data types must be declared using?
The new keyword and a special method of the same name as the data type called a constructor
What’s the syntax for composite
CompositeDataType variableName = new CompositeDataType();
What do the sObject composite data types represent?
sObjects in the Force.com database
What does a variable of an sObject represent
a single row of data in that sObject
How can initial field values be specified for sObjects
Using name value pairs
What are the three different types of collections in Apex?
Lists, Sets, Maps
What is a list
An ordered collection of primitive or composite data types distinguished by its index
What is a set
An unordered collection of unique data
What is a map
An unordered collection of unique keys that map to single values
Each element in a list contains two pieces of information?
An Index (integer) and a value (Data)
List for loops do what?
Iterate over all of the elements in a list one by one with the help of an iteration variable
Lists and maps can be up to how many levels deep?
5
Maps are often used to map what?
IDs to sObjects
An object oriented programming language uses
Classes, objects, modularity, inheritance, encapsulation
Classes model what?
real world ideals and consist of attributes and methods
Classes are where you define
attributes(nouns or adjectives) and methods (verbs)
Attributes describe?
properties
Methods describe?
Behavior
Class code syntax includes?
Access modifier, keyword class, unique class name, code block surrounded by curly braces
Can the class store attribute data or perform method actions
No, but it defines what objects created from the class can do
New attributes must be?
Declared
Attribute declaration includes
access modifier, data type, unique attribute name
Attribute example
public String name = ‘Toby’
Attributes can be?
Variables or Constants
Variables hold?
Data that is modifiable
Most attributes are?
Variables
Example of a variable
Integer that holds the earth’s population
Constants have what value?
a pre-defined, fixed value
Example of constant
the area of the earth
Variables allow developers
to write code without knowing exactly the data that will lie underneath