1.3 Use DML to manipulate data

The concept

SObjects are records in Salesforce platform. So they can definitely be persisted in Salesforce’s cloud database. The approach, is by using DML statements or Database class methods. Like SObject, DML statement is first class citizen in Apex. They will be treated as normal statements, instead of just strings in most other programming languages.

• • •

Introduction of using Apex in Salesforce platform

This is second part of the tutorial, which is about how to use Apex in Salesforce Platform. Essentially, if you have experience with Java or any other Object-Oriented Programming language, you can feel safe to jump directly here. You might still want to go over the first post of our last tutorial to have an understanding on where to write code. But other than that, you should be fine.

• • •

7.4 Nested usage of Map and List

The concept

The elements in list, set or map doesn’t have to be a primitive type. It can be another list, set or map as well. Here I am gonna show you an example of having list of string as element in a map. Let’s see if we have real world dictionary, one page can have multiple words but one word can only belong to one page number. Here is the code:

• • •

7.3 Introducing Map

The concept

Map can be considered as a collection of Key-Value pairs. It is like, for each word in dictionary, there is a page number associated with it. Let’s suppose one page can only accommodate one particular word. And that is pretty much what map is.

• • •

7.2 The differences between List and Set

The concept

In our last post, we have introduced Set. However, you might wonder, why do we want to use Set since List seems more convenient? Actually, although the grammars of Set and List may look similar, their data structure underneath is very different.

• • •

7.1 Using Set to store data

The concept

The usage of Set is very similar to List. But the elements are unique in Set and the sequence of elements in a Set is not fixed. So we can’t used the list way of list_name[index] way to reference a Set member. Let’s take a look at the code.

• • •

6.4 Merge two sorted list

The problem

Suppose we have two sorted Integer list, now we want to merge them together into one list. And it should still be sorted. For example, if we have these two lists:

• • •