Sub topic 1
The Problem: One Big Org, One Big Deployment
Prerequisites
Assume you know Salesforce objects, fields, Apex classes, permission sets, scratch orgs, Salesforce CLI, Git, and Apex test coverage.
The Problem: One Big Org, One Big Deployment
A Salesforce org often begins as one application. Over time, teams add sales, service, finance, and operations metadata to the same org. A single deployment then contains unrelated changes.
This creates coordination problems:
- A small change can be blocked by an unrelated change.
- Rollbacks are difficult because metadata has no clear ownership.
- Teams cannot release business capabilities independently.
- The deployment history does not clearly show which version is installed.
An unlocked package groups related metadata into a versioned, installable unit. The org still shares one Salesforce runtime, but the source and release process gains clearer boundaries.
Unlocked, Unmanaged, and Managed Packages
| Option | Versioned releases | Upgrade path | Typical use |
|---|---|---|---|
| Unlocked package | Yes | Install a newer version | Internal applications |
| Unmanaged package | No reliable upgrade model | Manual changes | One-time metadata distribution |
| Managed package | Yes | Subscriber-controlled upgrades | AppExchange or ISV products |
Change sets are another deployment method, but they move metadata between connected orgs without creating a source-controlled package version. Unlocked packages fit teams that own the target org and want repeatable releases.
Setting Up a Dev Hub
A Dev Hub is the Salesforce org that owns scratch orgs and package records. An administrator enables Dev Hub, then you authenticate the Salesforce CLI to it. You also need permission to create packages and package versions.
Use a separate Dev Hub from production when your governance model requires isolation. Keep the Dev Hub alias in team documentation and CI/CD configuration.
Defining Packages in `sfdx-project.json`
Each package directory contains metadata for one capability. The project file maps that directory to a package name and version:
{
"packageDirectories": [
{
"path": "force-app/core",
"package": "Core",
"versionNumber": "1.0.0.NEXT",
"default": true
},
{
"path": "force-app/sales",
"package": "Sales",
"versionNumber": "1.0.0.NEXT"
}
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "61.0"
}NEXT tells Salesforce to calculate the next build number for a package version.
Choosing Package Boundaries
Group metadata that changes, tests, and releases together. Business domains such as Sales or Service are useful starting points. Keep shared objects and permission sets in a Core package when several packages require them. Avoid splitting a package merely because its directory is large; excessive dependencies make releases harder to understand.
Exercise
Which package should contain a shared custom object used by both Sales and Service?
Show answer
Put it in a Core or shared package, then declare that package as a dependency of Sales and Service.