3.3 Use methods that takes parameters

The concept

In our previous post ,  we mentioned that variables can only store values. It doesn’t remember the formula. Remembering formula can be achieved via functions. Now let’s do it. We create a new class in our developer console called Commodity.

• • •

3.2 Use methods

The concept

Following our previous post , a dog not only has some attributes like name and gender, it can also do some certain behaviours. Like, they can bark, walk, they can greet you. When implemented in programming, such behaviours are defined as methods or functions. Method and function in apex can be used interchangeably. Here is the code, following our previous post:

• • •

3.1 Define a custom object using class

In this chapter, we are going to cover the very basics of custom class, object and method. Object-Oriented programming is a complicated concept and we will cover it in more details later. In this chapter, I will show you about how to create and use a custom class, and how to utilize methods to write dry code.

• • •

2.4 Variables only store data

The concept

A variable is a container of a small piece of information. And it only remembers the value of that information. It doesn’t know know how is that value generated or where it is coming from. This concept might seem easy, but it is worth taking some time really understanding it. Here is a sample code.

• • •

2.2 Variable types and conversions

The concept

In our last post, we mentioned that Apex is a strong typed language, which means each variable must have a type and that cannot be changed. In this post, I will show you a number of frequently used variable types in Apex and a few basic operations. Here comes the code:

• • •

2.1 Using variables to store information

The concept

There are always things we want to remember. We need to remember which tasks we need to work on. We need to keep track of grocery list we want to buy at the shopping centre. In those cases, if the information is hard for our brain to remember all of them, we write them down in a piece of page or track them down in the computer. So later we can find them.

• • •

1.3 Comments – why are they useful?

The concept

In short, comments are something which is for human to understand the piece of code, but doesn’t make any actual different to computer. Compilers will automatically ignore all the comments you have written in your code. So:

• • •