39 terms

Salesforce Platform Developer I: OOP in Apex


Terms in this set (...)

What is a class in Apex?
- A template or object-blueprint from which objects are created
- Consists of methods
- Store with API version of compiling it
- May contain other classes
What naming conventions should be used?
T/F: Can be enabled and disabled for profiles
How many levels deep can an inner class be nested?
One level
Where are static components declared?
In the top-level class definition
What base class should be used for custom exceptions?
What are the 2 ways to create a class?
1: Through the UI
2: Force.com IDE Project
Describe the GLOBAL class modifier
- Accessible within and outside the org or namespace
- Methods, attributes, and inner classes must be a global class to be global
What class modifier must be used with the WEBSERVICE keyword?
Describe the PUBLIC class modifier
Visible across app, org, and namespace
Describe the PRIVATE class modifier
- When used in inner class, the class is only visible to outer class
- Cannot be used for top-level or outer classes
- Default access to inner class is PRIVATE
Describe the WITH SHARING modifier
- Record-level sharing privileges are enforced
- In DML, user can update based on access
Describe the WITHOUT SHARING modifier
- Restrictions aren't enforced
- When not specified, this is default
How can interfaces be used?
- Include only method signatures
- Methods are not implemented in the interfaces
- Apex supports top-level and inner interfaces
What are attributes and methods?
Define behavior of objects
Is apex case sensitive?
What is the syntax for methods in apex?
- Defined in anonymous blocks, triggers, or stored classes
- Can be overloaded
- Can be used wherever System methods are used
What is the purpose of access modifiers for methods?
- Implement encapsulation
- Restrict devs from using non-exposed methods
- Allows devs to call only public methods
Describe the PRIVATE modifier for methods
- Default
- Implies attribute or method can only be accessed in class where it's defined
- Not available for top-level classes
Describe the PROTECTED modifier for methods
- Only available to inner classes
- Only instance methods and member attributes can use
Describe the PUBLIC modifier for methods
- Can be used in any apex code in the app or namespace where it is defined
Describe the GLOBAL modifier for methods
- Allows access to any apex code with access, not just apex in the application
- Class which contains global items must be global
Static methods
- Accessed through the class itself
- Does not depend on an instance of a class
Static attributes
- Store data shared within the class
- Prevent recursive logic by setting flags
- Assigned a value once
THIS Keyword, Dot notation
- Represents current instance of the class
- Call public methods or attributes
THIS keyword, with constructors
- Can do constructor chaining
- Must be the first statement in a constructor
What are 2 important system-delivered classes?
- System
- UserInfo
Describe System.debug()
Writes contents to debug log
Describe System.now()
Current time
Describe System.today()
Current date in current user's time zone
Describe System.Assert()
Throws an exception if contents are false
Describe System.assertEquals()
Throws an exception if contents are equal
Describe System.assertNotEquals()
Throws an exception if contents are not equal
Describe the UserInfo class
- Contains mostly getter methods for information about the current user (getUserId, getUsername, etc.)
What are limit methods?
Can be used for debugging and printing messages to avoid the limits that Salesforce places on resources.
What are the two things that each limit method returns?
1) Amount of resource used
2) Total number of resources available
What are some common limit methods?
- getDMLRows (# records processed in DML statements)
- getDMLStatements (# of DML statements processed)
- getHeapSize (amount of memory used in bytes)
- getQueries (# of SOQL queries issued)
- getQueryRos (# of records returned by SOQL queries)
- getScriptStatements (# of statements executed)
What are three system methods that can be used for programmatically processing approval processes?
- ProcessRequest (processes results from a workflow process)
- ProcessSubmitRequest (used to submit a workflow for approval)
- ProcessWorkItemRequest (processes an item after it's submitted)