What is Salesforce DX? The Definitive Guide

By David Runciman

February 21, 2022

What Are the Benefits of Salesforce DX?

DX isn’t just about developer tools. Salesforce’s overarching aim for DX was to support source-driven development, and this benefits everyone building on Salesforce. What’s more, it didn’t take long for Salesforce’s partners to build DX functionality into their DevOps solutions, making DX workflows accessible to no-code developers and admins. 

Today, you can spin up a new scratch org, create a new feature branch, make changes and deploy between those environments, pull in masked data from Production for testing, and merge to the main branch, all without touching the CLI. This means mixed teams of developers and admins can follow the same DevOps process, making the most of DX functionality, and using their preferred tools for development and releases.

Salesforce DX Tools and Features

Salesforce released a range of new and improved tools, APIs, and features as part of DX. These tools are all designed to work together and have the common aim of facilitating a package-based, source-driven development, and release process. But you can use some DX tools without needing to use them all. Your team’s workflow may or may not call for everything DX has to offer, and different members of your team will use the DX tools that make sense for their role.

The Salesforce CLI

The Salesforce command-line interface (CLI) superseded the Ant-based Force.com migration tool. It offers all the functionality of Ant and more, including commands for pushing and pulling metadata to and from orgs, converting metadata to SFDX format, and managing other DX features. If you’re a developer, you’ll want the Salesforce CLI bringing the power of DX to your fingertips.

Integrated Development Environment (IDE)

Salesforce also released extensions for Visual Studio Code that make the lightweight, extensible code editor an ideal IDE for working with DX, and which effectively replaced the Eclipse-based Force.com IDE that has since been retired. Salesforce continues to iterate on IDE tooling; this year it released Code Builder, a web-based development environment.

DevHub and Scratch Orgs

Scratch orgs were a DX innovation: temporary orgs that can be created as a fresh environment when wanting to start ‘from scratch’ (hence the name), then deleted, or allowed to expire. Scratch orgs exist for no longer than 30 days, but when spinning up a new scratch you can specify an even shorter lifespan, as well as the shape of the org and the features it has enabled. To create and manage scratch orgs, you need to enable a permanent org, usually Production, as a DevHub. Scratch orgs can be created from within the UI of a DevOps solution, or from the CLI.

Second-Generation Packaging (2GP)

Packaging your metadata avoids having an unstructured org, which can be more difficult to manage and modify because there’s no separation of concerns. Before DX, Salesforce already offered a way for teams to package up metadata into logical units that could be installed in orgs, but DX brought second-generation packaging (2GP) with a whole raft of improvements over 1GP. 

The most important change is that 2GP makes version control the source of truth for packages’ metadata, rather than a packaging org. These packages are also referred to as unlocked packages. If your team is going down the packaging route, use unlocked packages so you can follow a best practice DevOps process with version control.

A New Salesforce DX Metadata Format

Salesforce DX also introduced an improved format for metadata. The key difference is that big, complicated metadata types such as custom objects and translations are broken down into more manageable subcomponents when you switch to DX format. For developers, this change makes files much easier to work with in your IDE. 

The new metadata format also benefits the whole team by making merge conflicts less likely. When developers and admins make changes that affect the same files, they tend to run into merge conflicts that Git doesn’t know how to resolve. Splitting apart the metadata into smaller, separate files means teammates are more often working in different files and will have fewer merge conflicts to resolve.

Salesforce’s Dependency API

Among the upgrades to Salesforce’s APIs, the Dependency API is yet another feature of DX that helps teams understand and handle the complexities of orgs with countless dependencies between metadata. The Dependency API remains in beta, but can be used to query which components reference other components and vice versa.

Source: https://www.salesforceben.com/what-is-salesforce-dx-the-definitive-guide/

Leave a Reply

Your email address will not be published. Required fields are marked *