Technical benefits
Overview of the most important benefits and considerations for implementing D'fflib as an architect or developer.
Highlights & takeaways
D'fflib helps developers to excel in their deliveries, ensuring scalable, maintainable and testable Salesforce code.
It extends the proven fflib (apex-common) framework, but focuses on enabling developers while tackling some known challenges,
significantly extending the framework and improving performance.
Most developers know that feeling when looking back at their old code: recognising how far they've come, but also spotting the design choices they'd make differently now with more context and less time pressure. This becomes even more complex when joining an existing team and having to piece together an entire codebase and all the decisions that shaped it, from scratch. It's therefore no surprise that multiple cross-language principles and guidelines have risen (such as Object Oriented Programming, Model-View-Controller and Unit of Work) to help structure codebases and keep them maintainable.
fflib (apex-common) helps to apply
the theories of Single Responsibility Principle and Apex Enterprise Design Patterns
(Layered Architecture) in Salesforce development. When properly applied this leads to more maintainable,
scalable and testable code; which is significantly easier to understand and extend (by others).
D'fflib is a significant extension on top of fflib to focus on enabling developers to adopt and apply it faster and more easily.
It provides technical enhancements, performance improvements, and shortcuts to reduce the number of (repetitive) code lines and
the time needed to learn the framework to deliver effective and modular code.
It is released as an extension after close alignment and collaboration with the Apex Enterprise Patterns (AEP) core team (maintaining fflib).
Providing you two (unlocked) packages: 1) the full package, including apex-common and apex-mocks and thus reducing technical debt
for package management etc; or 2) the "D'fflib only" package, which only ships our extensions, to keep control of which fflib version is used
(e.g. with customisations), thus also owning full dependency control.
Main benefits
Understandable and maintainable code
By the well-defined structure, every developer becomes able to - more easily - find functionalities, even when delivered by another team (member). The framework supports a guided application of industry standards, but doesn't enforce it (allowing a phased rollout). This results in modular, easier-to-read and maintainable code.
Unlocking scalable and testable applications
Applying fflib unlocks out-of-the-box mocking support, enabling a significant reduction in
unit test runtime (40-50%, up to 60% with D'fflib's additional framework enrichments) while strengthening unit test quality through simplified testing.
Due to the Single Responsibility Principle, each test only needs to validate the method's own functionality
and can disregard (mock/fake) other consumed methods, as those are covered in their own unit tests.
Accelerators, frameworks and less repetitive code
While Apex already takes care of quite some stuff (like memory management) there is still quite some repetitiveness
in writing code like exception handling and security enforcement. fflib helps to reduce this with
pre-built structures and base-classes, allowing developers to focus on the actual business logic.
D'fflib even takes this a step further by providing additional accelerators
and frameworks (like for Trigger Handlers and Test Data Builder Framework).
This way developers can focus on 'the fun stuff', while reducing lines of code and thus delivering more readable solutions.
AI enabler for faster, more accurate, first-time-right AI-responses
D'fflib's consistent structure and clear separation of concerns give AI tools unambiguous context about your codebase. LLMs can recognise and understand well-known architectural patterns and therefore more easily locate the right components and generate accurate, targeted results without having to understand the entire codebase for each prompt. While additionally reducing the risk of an AI-generated change to unintentionally impact other areas.
With the full documentation website and a set of ready-to-apply AI skills, you're directly enabled to leverage all AI-benefits while reducing repetitive back-and-forth and token usage.
Significant delivery and performance improvements
D'fflib provides some significant performance improvements (>14x faster database interactions compared to fflib),
while allowing calling classes to define the sharing/database context the logic should run with.
This eliminates the need for local project customisations with own IDMLs or without sharing inner classes.
Additionally, this resolves the challenge of fflib where selector methods can't be tested.
Fit-for-future
Being fully metadata driven D'fflib allows you to split codebases into smaller packages. This can modularise your application and enable autonomous development cycles with scratch orgs etc, while reducing dependencies between teams.
Up-to-date & community-driven
Both fflib and D'fflib are open-source frameworks, allowing anyone to contribute. While fflib was initiated by
Andrew Fawcett and D'fflib by Deloitte, there is no restriction or limitation to these founders.
This community interaction ensures the framework is kept up-to-date with latest best-practices and features,
but also ensures edge cases can be openly discussed and aligned upon.
Framework details
Benefits of D'fflib
- Focused on enabling developers, an extended framework, tailored to reduce lines of (repetitive) code
- Enabling developers with all latest Salesforce feature
- Significant performance improvements (for your end-users)
- Simplified and standardised usage, flattening learning and adoption curve
- Resolving several known fflib challenges
- Simple install and upgrade via (unlocked) package link
- Only one package to maintain, reducing technical debt and dependencies
→ Click to see all benefits.
Maintained and supported by an active community
- D'fflib provides full documentation (for both fflib and D'fflib) on edge cases or basic steps
- D'fflib provides AI-skills to enable developers and their agents
- The active community ensures continuity in improvements, like adopting the latest Salesforce features
- With the unlocked package urls newer versions can be swiftly installed or upgraded
→ Click to read more about available support.
Implementation efforts
Efforts might vary per organisation depending on the current codebase, team experience, and project complexity.
Install (5 min) or upgrade (1 day)
With the unlocked package link, installation and future updates are only a matter of minutes.
Upgrading from fflib does require some steps, but is fully documented, like an Anonymous Apex
script to automatically generate the metadata records based on the existing Application class.
Training
This completely depends on the experience of your developers with layered architectures and/or other frameworks.
We recommend ensuring some senior developers are trained first, allowing them to guide others while gradually
adopting the framework in your codebase. This can be by
Trailheads or the materials on this website.
If desired, we are happy to support, e.g. with training sessions (4 hours to 2 days, depending on demand).
Phased roll-out (weeks to months)
Depending on your current codebase there are different strategies to roll-out fflib.
- Foundational: Move low-increment changes to fflib first, having the structure set up and first files created
- New development: Apply fflib only on new development work, gradually increasing the coverage
- Full refactor: Move all existing code to fflib in one go
Each strategy has its pros and cons, and the choice depends on your organisation's priorities and resources. In doubt what strategy to apply? Our fflib tailored maturity assessment can help to understand your status quo, and provide concrete actions including their potential (business) benefits.