Salesforce and Namespaces

Instead of dumping you people with the technical definition of what namespace is, I would like to show you a simple example

I am pretty sure you are aware of test methods in salesforce Test.StartTest() and Test.StopTest()

Lets say you created a class with name Test and method with the name StartTest

public class Test{
public void StartTest(String s){


Now lets try running a test class

Test.StartTest() will give you an error but System.Test.StartTest() runs successfully. Why?

That mystery behind this is apart from the organization namespace that each Salesforce organization have, there is a namespace called System that is commonly available to all the salesforce organizations.

In this example the compiler checks if there is a class called Test in your organization namespace. Next if looks for Test in System namespace. What we did here was we accidentally overrided System namespace class.

Now I will give you the technical definition of Namespace. “A namespace is an abstract container or environment created to hold a logical grouping of unique identifiers or symbols”.



Leave a Reply

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

You are commenting using your 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 )

Connecting to %s