Skip to main content
Free Agentforce workshops and AI Certifications: Learn more. Terms and conditions apply.

Get Started with Coding Conventions

Learning Objectives

After completing this unit, you’ll be able to:

  • Describe what coding conventions are.
  • Explain why coding conventions are beneficial.

From Pure Beauty to Chaos

Let's take a moment to appreciate one of the most beautiful things in the Salesforce ecosystem: a brand-new org. A brand-new org is Salesforce in its purest form, untouched by human hands, ready to explore whatever future lies ahead.

But new orgs grow up fast. As the org grows, it gets more complicated and soon runs into trouble. We’ve all seen complex orgs filled with inconsistently named validation rules, puzzling trigger structures, and uncommented code. Finding and understanding things you created becomes difficult. Finding and understanding the creations of your colleagues becomes nearly impossible. If only there were a way to minimize these challenges, add some structure to your org, and ensure that everyone using it speaks the same language.

Coding Conventions to the Rescue

Coding conventions are guidelines for styling and structuring your code. They add consistency and ensure that everyone on the team adheres to the same principles. Coding conventions come in many shapes and forms, but in this module we focus on three types.

  • Naming conventions are guidelines for naming the most common Salesforce elements, such as Apex classes and process builders.
  • Frameworks are prebuilt structures that make your code reusable, maintainable, and efficient.
  • Best practices are general recommendations for Apex coding.

A common misconception is that coding conventions limit a developer's creativity. In fact, coding conventions focus exclusively on the style and structure of your code, not the content or functionality. Adhering to coding conventions is like writing a book. An editor can require the author to structure the book with chapters, avoid abbreviations, and write in formal language. Within those requirements, however, the author is free to really let their creative juices flow.

The Coding Convention Advantage

Using coding conventions helps Salesforce customers to be more successful.

  1. Coding conventions impose standardization.
  2. Standardization makes it easier to debug and maintain code.
  3. That decreases the number of bugs, which helps you to deliver higher quality Salesforce solutions to your customer.
  4. Higher quality Salesforce solutions lead to lower attrition and higher customer satisfaction scores (CSAT).

Get Your Team on Board

Now that you know how awesome coding conventions are, you probably want to start using them right away. And the great thing is that you can. You don’t need any tools or software to use coding conventions in your projects. All you need is your team’s agreement to follow the coding conventions.

Coding conventions are only effective when the whole team uses them. That’s why it’s important to discuss coding conventions early. The specific conventions that your team adheres to are not as important as commitment from the whole team to adhere to them. Only with full team commitment can you reap the benefits of using code conventions.

Defining coding conventions is not a one-off exercise; developers will use them for all future development. Coding conventions transcend individuals and teams. That’s why it’s so important to define good coding conventions early in your development process!

The rest of this module details the coding conventions that the Salesforce Success Cloud team adheres to. These conventions were constructed by our smartest architects, who have centuries worth of combined experience worldwide. If you are ready to make your Salesforce development work more fun, and empower your customers in the process, then keep reading.

Resources

Partagez vos commentaires sur Trailhead dans l'aide Salesforce.

Nous aimerions connaître votre expérience avec Trailhead. Vous pouvez désormais accéder au nouveau formulaire de commentaires à tout moment depuis le site d'aide Salesforce.

En savoir plus Continuer à partager vos commentaires