This is the basic syntax for declaring classes with Apex.

private | public | global
[virtual | abstract | with sharing | without sharing]
class ClassName [implements InterfaceNameList] [extends ClassName]
{
// The body of the class
}

Understanding classes (from Apex code developers guide).

As in Java, you can create classes in Apex. A class is a template or blueprint from which objects are created. An object is an instance of a class. For example, the PurchaseOrder class describes an entire purchase order, and everything that you can do with a purchase order. An instance of the PurchaseOrder class is a specific purchase order that you send or receive.

All objects have state and behavior, that is, things that an object knows about itself, and things that an object can do. The state of a PurchaseOrder object—what it knows—includes the user who sent it, the date and time it was created, and whether it was flagged as important. The behavior of a PurchaseOrder object—what it can do—includes checking inventory, shipping a product, or notifying a customer.

A class can contain variables and methods. Variables are used to specify the state of an object, such as the object’s Name or Type. Since these variables are associated with a class and are members of it, they are commonly referred to as member variables. Methods are used to control behavior, such as getOtherQuotes or copyLineItems.

A class can contain other classes, exception types, and initialization code.

An interface is like a class in which none of the methods have been implemented—the method signatures are there, but the body of each method is empty. To use an interface, another class must implement it by providing a body for all of the methods contained in the interface.

Apex supports primitive data types like Java. It also supports sObjects. Which are basically Salesforce objects; like a table.

Additionally, a data type can be a typed list of values, also known as an enum. But watch out, because these aren’t the same enums you’re used to working with in .NET. In Apex, you can use enums with numbers, but you can’t define what these number values are. Also, the ordinal assignment starts at zero. For example, if you had an enum like the following.

public enum myEnums {
            Enum1,
            Enum2,
            Enum3
 }

Apex has the following 3 collections:

    1. List. A list in an ordered collection of elements that works much the same as a traditional array.
      List myStrings = new List();
      myStrings.add('String1');
      myStrings.add('String2');
      myStrings.add('String3');
    1. Set. A set is an unordered collection of elements that does not contain duplicates.
      Set accountIds = new
      Set{'001d000000BOaHSAA1','001d000000BOaHTAA1'};
      List accounts = [SELECT Name
      FROM Account WHERE Id IN :accountIds];
    2. Map. A map is a collection of key-value pairs.
      Map<Id, Account> accountMap = new Map<Id, Account>([SELECT Id, Name FROM Account]);

 

The class and its underlying object are essentially a mirror image of one another that is constantly in sync.

Unit tests.

On the Force.com platform is that you must have 75% test coverage to deploy your Apex code to a production org.

Not only does having unit tests promote the development of robust and error-free code, but they’re vital to the stability of the platform, because all tests are run before every major release. To learn more about unit testing, see An Introduction to Apex Code Test Methods.

I found this code online because there was a bit of a gap in my knowledge of the challenge. However, I think I understand that it declares a class called AccountUtils. The class contains a method that returns a list. The list is of accounts and includes the ID and name from accounts where the billing state equals the string passed to the method, which is an abbreviation for the state.

public class AccountUtils {public class AccountUtils {
public static List accountsByState(String st){
List acctList = [SELECT Id, Name FROM Account WHERE
billingState = :st];
return acctList;
}
}

I do believe that this statement nested in the method where it says SELECT and WHERE is SOQL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s