Integrated Development Environment
Let's refer to the coffee making code:
get cup = 1 unit;
get coffee = 100 grams;
get water = 500 ml;
get pot;
get timer;
get frenchPress;
put cup, frenchPress, pot on table;
pour water(500 ml) in pot;
start pot;
set timer = 60 seconds;
put coffee(100 grams) in frenchPress;
pour 1/5 water from pot in frenchPress;
set timer = 30 seconds;
pour water from pot in frenchPress;
set timer = 5 minutes;
pour everything from frenchPress to cup;
drink;
The first step to making coffee was to enter the kitchen. The equivalent to which is using an IDE (Integrated Development Environment).
An IDE or Integrated Development Environment is a combination of text editor and tools that make writing, running and error reporting (debugging) easier. Throughout this course, we will be using 2 IDEs.
- Salesforce Developer Console
- Microsoft Visual Studio Code
Since we are just starting out, we will be using Salesforce Developer Console.
For this, we will be using our Developer Org. A developer org is a Salesforce instance that is used to test and debug SF Applications and Code. If you don't have a Salesforce Developer Org yet, here's how you make it:
- Head over to Salesforce Developer Website and sign up.
- Click on your name, and click on My Developer Account


Variables and Data Types
Now that we are in our kitchen (the developer console), let's make some coffee.
The first step was to gather our materials.
get cup = 1 unit;
get coffee = 100 grams;
get water = 500 ml;
get pot;
get timer;
get frenchPress;
We need to gather our basic materials to build on them further. You have materials that have the sole purpose of holding coffee/sugar/water in them. You have materials with the purpose to process its contents, like the pot boiling water
or using French Press to filter the coffee. Then we walk away from the kitchen using just one cup filled with processed/mixed ingredients. The "cups" in code that hold your materials are called Variables.
Variables are called so because they can vary, meaning their content can change over time just like the cup was first used to hold water, then ground coffee, then finally the prepared coffee. Unlike real life the cup that was used to hold multiple contents of different types, a variable can hold content of only one type and this is called its Data type.
A data type is just the programmer telling the computer how they intend to use the variable. It's similar to playing fit the shape game from kindergarten. A star hole(data type) will only allow a star(data) to be fit inside. There are two kinds of Data Types in Apex
- Primitive Data Types
- Complex Data Types
Primitive data types are the simplest data types to define.
- Blob
- Boolean
- Date
- DateTime
- Decimal
- Double
- ID
- Integer
- Long
- Object
- String
- Time
Complex Data types are based on needs of the programmer.
- Class Object
- Enumerator
- List
- Map
- Set
- sObject
For example, a List can hold a group of IDs, Strings, Decimals and Integers at the same time. A List could also contain multiple lists within itself! The usage of complex data types are completely dependant on how the programmer intends to use it.
Syntax
Every language has its own grammar, the same applies to programming languages. Every programming language has its own set of strictly defined grammar called syntax.
The grammar(syntax) to make new variables and define their data types is
dataType variableName = value;
dataType
is one of the primitive or complex data types.variableName
is how we use this variable later.=
is the assignment operator. This means, assign the value on the right, to the variable on the left. More on operators and how they function is later in the course.value
is the final value being assigned to the variable.;
defines end of line / block.
variableName
could be written as VariableName
, but it's a good practice to lower case the first
letter of the first word and
then capitalize first letter of following words. Apex is a case-insensitive language, so variableName
and VariableName
both mean the same variable. A lot of other programming languages like Python and Swift would
see variableName
and VariableName
as two separate entities. In future lessons, you'll realize how most of the code you write is simply syntax populated with logic and data types.
Data Types: Basics
Let's dive into basics of Data Types in an order of ease of understanding.
- ID The ID data type holds Salesforce IDs inside single quotes. An ID can be any valid 18 digit character that represents an ID.
ID nameID = '00300000003T2PGAA0';
String siteName = 'Admin2Dev';
,
and spaces are not allowed.
Integer positiveNumber = 10000;
Integer zero = 0;
Integer negativeNumber = -100;
,
and spaces are not allowed.
Decimal positiveNumber = 1.45;
Decimal zero = 0.0;
Decimal negativeNumber = -1.45;
,
and spaces are not allowed.
Double positiveNumber = 1.45;
Double zero = 0.0;
Double negativeNumber = -1.45;
,
and spaces are not allowed.
Long positiveNumber = 100;
Long zero = 0;
Long negativeNumber = -100;
Summary
- An IDE (Integrated Development Environment) is where we write, run and debug code.
- Variables hold data that can change over time.
- Data types define what type of data a variable will hold.
- There are primitive and complex data types.
- Primitive data types are simple numbers, texts and Salesforce IDs. Complex data types are dependant on how the programmer intends to use them.
- The grammar of a programming language is called a Syntax and must be strictly followed.