Other alternatives
Highlighting benefits and challenges from other well-known Apex coding frameworks.
Highlights & takeaways
We understand that different projects have different needs, and we encourage architectural evolution over time. However, to avoid architectural drift, and based on our experience that every codebase eventually grows driven by business demand, we'd always suggest a solid framework like (D')fflib for any project. This reduces ambiguity, enforces separation of concerns, and provides a sustainable structure that stands the test of time.
The Apex architecture landscape
Over time, we've seen three broad categories of architectural guidance emerge in the Salesforce Apex ecosystem, each with a different philosophy and trade-off profile:
- Frameworks (e.g. D'fflib,
fflib) impose a layered structure upfront, reducing ambiguity and enforcing separation of concerns across the entire codebase. Trade-off: more code, steeper initial learning curve, less flexibility for small projects. - Principles (e.g.
AWAF) provide guiding philosophies that teams interpret and apply independently, prioritising flexibility and developer autonomy. Trade-off: harder to apply consistently across teams; divergence grows over time. - Libraries (e.g.
Force DI,SOQL-Lib,Apex Fluently) provide targeted utilities that solve specific problems and can be composed alongside any architectural approach. Trade-off: no structural guidance; integration, compatibility and dependency maintenance are your responsibility.
In our experience, no codebase stays simple forever — the architectural decisions made early tend to compound, for better or worse, as teams and requirements grow. As Andrew Hunt & David Thomas famously observed in The Pragmatic Programmer:
No one in the brief history of computing has ever written a piece of perfect software. It's unlikely that you'll be the first.
It is with that reality in mind that we explore the approaches available to Apex development teams today.
The table below compares these categories across dimensions, providing references to deep-dives later on the page, and a table of alternatives used for this article at the end.
| Dimension | Frameworks e.g. fflib, D'fflib | Principles e.g. AWAF | Libraries e.g. Force DI, SOQL-Lib |
|---|---|---|---|
| Ambiguity / Objectivity | Low ambiguity — shared conventions make code reviews objective | Higher ambiguity — principles require interpretation, leading to divergent implementations | N/A — libraries solve specific problems, not structural ambiguity |
| Onboarding time | Weeks — structured onboarding path via external resources (Trailhead, books, community) | Weeks — team-specific docs required; no shared external reference | Days — typically low for individual tools |
| Junior developer paradox | Framework scaffolding accelerates growth — "put this logic here" is actionable | Principles require interpretation before application — harder for developers still building mental models | Not applicable at the architectural level |
| Maintenance / Dependency | Single external dependency, one provider — trust one established codebase | Requires assembling 3–5 utilities with independent release cycles; principles often additionally recommend library adoption, increasing the total dependency surface | Each library has its own maintainer and roadmap — integration is your responsibility |
| Documentation | Powered by external resources — Trailhead, books, community posts supplement internal docs | Each team's unique approach requires bespoke documentation | Library-specific docs only; no cross-library architectural narrative |
Exploring Apex architecture options
With the landscape above as context, the rest of this page examines where D'fflib excels, where the trade-offs become visible, and how the alternatives compare in practice.
What D'fflib is designed to solve
At its core, D'fflib originates from conventional enterprise application architecture, where layered systems are used to control complexity.
The framework's philosophy is to impose structure early, to reduce ambiguity and to prevent architectural drift as teams and codebases grow. Its purpose is not developer convenience — it is system stability at scale. The core problems it addresses are consistent across every enterprise Salesforce engagement we've been part of:
- Uncontrolled growth of business logic
- Lack of architectural consistency across teams
- Slow, database-dependent test suites
- Long-term maintainability risk as systems scale
These aren't hypothetical risks — they're the most common reasons mature Salesforce orgs become expensive to change. For a deep-dive into each, see our Technical benefits and EDP & fflib pages.
How it creates value over its compromises
D'fflib is designed to help teams manage complexity as systems grow, but that strength also brings trade-offs worth understanding before adoption.
Benefits
Trade-offs
Addressing common framework challenges
Approaches like AWAF champion principles over structure, which is a philosophy that works well for teams with strong architectural alignment. Below we examine the most common challenges that arise in practice.
Principles empower, but also diverge
AWAF's principle-driven approach is designed to give teams freedom to find their own "vibe." We respect that intent. In practice, though, that freedom means every project will interpret and apply those principles differently. Over time, that divergence is likely to incur organisational costs, due to steeper learning curves, longer onboarding times and team discussions on the proper principle application. Our recommendation remains D'fflib for most enterprise projects, precisely because it converts that freedom into a shared, navigable structure.
Structural divergence across projects
When each project finds its own structural interpretation, the codebase of Project A will look meaningfully different from Project B. Even if both teams followed the same principles in good faith. Moving a developer between projects requires significant ramp-up time to understand the local conventions, abstractions, and design decisions that emerged organically.
With D'fflib, fewer iterations are needed to reach an empowering structured base. Patterns are recognisable across codebases, and developers transition more quickly because the framework, not the team's interpretation of principles, defines the structure. This matters especially for organisations staffing multiple Salesforce projects simultaneously.
The junior developer paradox
A common argument is that frameworks are harder to learn than principles, especially for the self-taught admins and business analysts who make up a large portion of the Salesforce ecosystem.
We'd argue the opposite is often true. Principles require interpretation: a developer must first understand the principle, then decide how to apply it in their specific context, then defend that decision in a code review. A framework requires application: "put this type of logic here." That strictness is not a limitation, it is scaffolding. Developers grow through it, not despite it, and they reach the next seniority level more easily because the framework gives them a clear structure to discuss, challenge, and eventually transcend.
For a deeper look at how D'fflib supports developers at different seniority levels see Guidelines → FAQ → Who are these guidelines for?
Review objectivity and "rogue classes"
Without a shared framework, code reviews become debates about intent. "Is this separation of concerns correct?" is a subjective question, where the answer depends on how each reviewer interprets the underlying principle. Well-intentioned developers applying principles independently can produce "rogue classes" that are structurally sound by their own reasoning but inconsistent with the rest of the codebase.
Framework-based reviews are more objective: "Does this query belong in the Selector?" is a verifiable question. Reviews become teaching moments grounded in shared conventions, not hunches, and that consistency compounds over time as the team grows.
Documentation & onboarding
Each team's unique architectural approach requires its own documentation and onboarding materials. A shared framework is powered by external resources, like Trailhead modules, books, community posts, supplemented by internal documentation which all reduce onboarding burden.
Both approaches produce working software. The question is which learning path fits your team's composition and growth goals.
Junior developers can't be expected to read principles and independently internalise how to apply them. A framework gives them comparable classes to study, a predictable structure to reason about, and code reviews grounded in shared conventions rather than individual judgement. Over time, developers absorb the why by living it, and once they understand the framework deeply enough to challenge it, they've already grown into the seniority level where that challenge is productive.
One of the most concrete expressions of this is how D'fflib handles the boundaries between its own layers (particularly how Services and Domains interact), and how the framework approaches dependency injection. Rather than prescribing rigid rules, D'fflib provides vocabulary for ongoing team discussion. Read more on the Services layer page.
Alternative approaches & the assembly trade-off
One critique of D'fflib is the dependency on external code — "importing a tool where maintenance is not guaranteed". This is a fair concern worth examining honestly.
For a full overview of compared architectural guidances, see Architectural guidances compared below.
Unified framework
Assembled libraries
Consider the alternative maintenance surface
Assembling an architecture from multiple independent libraries — each with its own maintainer, release schedule, and roadmap — introduces a maintenance surface that is often larger than adopting a single unified framework. Connecting those libraries, keeping them updated, managing version compatibility between them, and absorbing the risk of any one losing active support are all costs that land on your team.
With D'fflib, you trust one established ecosystem with 10+ years of production validation. With an assembled stack, you own the integration. Neither approach eliminates maintenance risk entirely, so the question is where that risk lives and who manages it.
Architectural guidances compared
The following table offers a structured overview of alternatives for teams with different constraints, inspired by the Harrier documentation's discussion:
| Alternative / Pattern | Type | When It Fits |
|---|---|---|
| Apex Fluently | Utility | A set of single-class injectable utilities for targeted functionality. Useful alongside any architectural pattern for teams wanting lightweight, composable utilities. |
| AT4DX/Apex Framework Patterns | Framework | A broader set of best practices for folder structure, naming conventions, and intent. Especially once an organisation has settled on how it wants to evolve its architecture. |
| AWAF (Apex Well-Architected Framework) | Principles | Teams that prefer progressive adoption over upfront architectural overhead, with a how code feels and reads mindset. Best suited for small- to mid-projects emphasising clean code and Salesforce-first pragmatism. Note: teams must maintain 3–5 separate utilities with independent release cycles. |
| fflib Apex Extensions (Wim Velzeboer fork) | Framework | Teams that want D'fflib plus a richer set of patterns and helpers to reduce repetitive boilerplate without abandoning architectural discipline. |
| Force DI (Dependency Injection) | Utility | When your primary need is dependency management to inject mocks cleanly without adopting a full architectural framework. |
| SOQL-Lib | Utility | Not an architectural framework; a focused utility. Use it alongside any architectural pattern to reduce SOQL complexity and duplication. |
Each alternative occupies a different part of the architecture vs utility vs principle trade-off space. Understanding where your pain points lie helps in choosing the right blend. We understand that different teams have different constraints, and we encourage evolution over time. However, based on our experience, D'fflib remains the approach that most consistently reduces that overhead and we'd always recommend starting there.
Our final thoughts
Architecture is not a one-size-fits-all decision. Team size, org maturity, domain complexity, and expected lifespan all play a role. Most approaches in the Salesforce ecosystem exist to solve the same underlying problem: keeping codebases understandable, testable, and maintainable as they grow. The right question is rarely "which framework is better?" but rather:
What level of structure does your organisation need right now, and how will that change over time?
Our experience consistently shows that most development teams benefit from the clear structural guidance a framework provides and D'fflib, in particular, reduces ambiguity, accelerates onboarding, and prevents the architectural drift that makes codebases expensive to change over time. In our honest (and likely subjective) opinion, it remains the recommended choice for enterprise-grade Salesforce development. Nevertheless, the choice is ultimately yours to make based on what serves your team best.