There are several development environments for developing Apex code. The Developer
Console and the Salesforce extensions for Visual Studio Code allow you to write, test, and
debug your Apex code. The code editor in the user interface enables only writing code and
doesn’t support debugging.
Developer Console
The Developer Console is an integrated development environment with a collection of
tools you can use to create, debug, and test applications in your Salesforce
organization.
The Developer Console supports these tasks:
- Writing code—You can add code using the source code editor. Also, you
can browse packages in your organization.
- Compiling code—When you save a trigger or class, the code is
automatically compiled. Any compilation errors will be reported.
- Debugging—You can view debug logs and set checkpoints that aid in
debugging.
- Testing—You can execute tests of specific test classes or all tests
in your organization, and you can view test results. Also, you can inspect
code coverage.
- Checking performance—You can inspect debug logs to locate performance
bottlenecks.
- SOQL queries—You can query data in your organization and view the
results using the Query Editor.
- Color coding and autocomplete—The source code editor uses a color
scheme for easier readability of code elements and provides autocompletion
for class and method names.
Salesforce Extensions for Visual Studio Code
The Salesforce extension pack for Visual Studio Code
includes tools for developing on the Salesforce platform in the lightweight,
extensible VS Code editor. These tools provide features for working with development
orgs (scratch orgs, sandboxes, and DE orgs), Apex, Aura components, and
Visualforce.
See the website for information about installation and usage.
Code Editor in the Salesforce User Interface
The Salesforce user
interface. All classes and triggers are compiled when they are saved, and any syntax
errors are flagged. You cannot save your code until it compiles without errors. The
Salesforce user interface also numbers the lines in the code, and uses color coding to
distinguish different elements, such as comments, keywords, literal strings, and so on.
- For a trigger on an object, from the object’s management settings, go to
Triggers, click New, and then enter your code in the
Body text box.
- For a class, from Setup, enter Apex Classes in the
Quick Find box, then select Apex
Classes. Click New, and then enter your
code in the Body text box.
Alternatively, you can use any text editor, such as Notepad, to write Apex code. Then
either copy and paste the code into your application, or use one of the API calls to
deploy it.