# D'fflib > D'fflib is the open-source developer-experience focused extension of fflib (Apex Enterprise Patterns) for Salesforce. fflib provides the proven architectural foundation for Enterprise Design Patterns in Apex. D'fflib improves developer-experience by lowering its complexity and learning curve: less repetitive code and fewer conventions to remember, so developers and AI agents deliver scalable, maintainable and testable code faster. - Open source under the BSD-3-Clause licence (same as fflib); fully backward compatible with `fflib-apex-common` and `fflib-apex-mocks` syntax. - Installed as an unlocked package: framework code and its unit tests stay out of your codebase. ## Main additions - One signature across layers, e.g. `defineMock()` to mock any layer and one way to set the Database Context (User vs System mode, relevant from API 67) on Selectors and Unit of Work; enables unit-test assertions on selector queries. - Redesigned Unit of Work (~14x faster DML); all Database methods supported in QueryFactory and Unit of Work. - Metadata-driven Application layer: registrations in custom metadata instead of the Application class (package-ready, no merge conflicts). - Trigger Handler and Test Data Builder frameworks, plus accelerators for input validation, collection processing and common exceptions. - Signatures and usage of all `dfflib_` classes are documented on this site; use it as the source, not upstream fflib knowledge. ## How to read this site - The documentation is organised as WHY (evaluation and benefits), WHAT (features) and HOW (implementation). - The HOW layer pages (Domains, Selectors, Services, Unit of Work, Trigger Handlers, Entrypoints, Testing and Mocking) are the authoritative implementation reference. Start there for writing or reviewing code. - The HOW pages also serve plain fflib users: they document the standard fflib patterns, with D'fflib-specific parts marked as extensions. - The HOW Overview page can help to determine the best layer for a specific piece of functionality, including nuances. - Code snippets are taken from the D'fflib code-examples project (a Room Booking domain) and link to the source files on GitHub. - The full content of every page in one Markdown file: [llms-full.txt](/dfflib/llms-full.txt) ## Implementation reference (HOW - layers) - [Domains](/dfflib/docs/how/domains/): Step-by-step guide on how to set up and interact with a Domain, maximise the functions and benefits, while being aware of edge cases and D'fflib specific functionalities. - [Entrypoints](/dfflib/docs/how/entrypoints/): Step-by-step guide on how to set up and interact with an Entrypoint, maximise the functions and benefits, while being aware of edge cases and D'fflib specific functionalities. - [Selectors](/dfflib/docs/how/selectors/): Step-by-step guide on how to set up and interact with a Selector, maximise the functions and benefits, while being aware of edge cases and D'fflib specific functionalities. - [Services](/dfflib/docs/how/services/): Step-by-step guide on how to set up and interact with a Service, maximise the functions and benefits, while being aware of edge cases and D'fflib specific functionalities. - [Testing & Mocking](/dfflib/docs/how/testing-mocking/): Elaborating on the benefits of mocking, and how to properly set up test data to mock methods with. Including thorough and extensive example code snippets. - [Trigger Handlers](/dfflib/docs/how/trigger-handlers/): Step-by-step guide on how to set up and interact with Trigger Handlers, maximise the functions and benefits, while being aware of edge cases and D'fflib specific functionalities. - [Unit of Work](/dfflib/docs/how/unit-of-work/): Step-by-step guide on how to set up and interact with the Unit of Work, maximise the functions and benefits, while being aware of edge cases and D'fflib-specific functionalities. ## Getting started & guidelines (HOW) - [Get started](/dfflib/docs/how/get-started/): Learn how to easily install, upgrade or update D'fflib in your Salesforce environment, and what is needed to maximise framework benefits. - [Adoption](/dfflib/docs/how/adoption/): Apply D'fflib gradually in your codebase and enable your team: a recommended layer sequence, refactoring decisions, team learning and AI-assisted development. - [Layers explained](/dfflib/docs/how/overview/): The entry point for HOW articles, describing the different (D')fflib layers, their responsibilities and interactions; and introducing the Room Booking use-case which is used across all code examples in the layer-specific articles. - [Guidelines](/dfflib/docs/how/guidelines/): Elaborating on our guidelines to help smoothen implementation, though project-consistency should always be prioritised. ## Features (WHAT) - [EDP & fflib](/dfflib/docs/what/fflib-enterprise-design-patterns/): Explaining the foundations of our D'fflib framework: Enterprise Design Patterns and fflib. - [D'fflib](/dfflib/docs/what/dfflib/): Elaborating on the origin, reasoning and purpose of D'fflib. - [Accelerators & Utilities](/dfflib/docs/what/accelerators-utilities/): Our ambition is to reduce code repetitions and ease the life of developers, therefore a proper set of utilities and accelerating methods and defaults couldn't be missed. - [Database context](/dfflib/docs/what/database-context/): D'fflib uses the user mode features from Spring '23 (API 57) to simplify how you control sharing and FLS/CRUD, and to (finally) enable proper unit tests for selectors. - [Metadata driven](/dfflib/docs/what/metadata-driven/): D'fflib is fully metadata-driven, meaning all layer definitions and configurations are stored in metadata files. Originally these definitions/mappings were hardcoded in Apex classes, which increased the risk for conflicts. - [Unit of Work 2.0](/dfflib/docs/what/unit-of-work/): Being 14x faster than the original construct, the Unit of Work 2.0 fully focuses on relaxing developers from any DML related activity. - [Selectors 2.0](/dfflib/docs/what/selectors/): Providing full SOQL support, while unlocking proper unit test methods for the selector layer. - [Test Data Builder Framework](/dfflib/docs/what/test-factory-builder-framework/): D'fflib ships a complete Test Data Builder Framework to quickly set up typed, fluent test data — including parent and child relations, formula fields and read-only fields — without touching the database. - [Trigger Framework](/dfflib/docs/what/trigger-framework/): D'fflib comes with an extended trigger framework, enabling bulkified, scalable and maintainable trigger handlers. ## Evaluation (WHY) - [Business benefits](/dfflib/docs/why/business-benefits/): D'fflib unlocks scalable and maintainable applications which can significantly reduce your delivery overhead. - [Technical benefits](/dfflib/docs/why/technical-benefits/): Overview of the most important benefits and considerations for implementing D'fflib as an architect or developer. - [Open-sourcing D'fflib](/dfflib/docs/why/dfflib-open-source/): Why Deloitte decided to open-source their enriched version of fflib. - [Other alternatives](/dfflib/docs/why/comparison/): Highlighting benefits and challenges from other well-known Apex coding frameworks. ## Optional - [Welcome to the D'fflib documentation](/dfflib/docs/welcome/): Here you find what and why we open-sourced, and how to maximise this framework's benefits. - [Support](/dfflib/docs/how/support/): Find the right channel for your current needs. Whether it's a bug, feature request, suggestion, maturity assessment, training or step-by-step support, we're happy to support! - [Frequently Asked Questions](/dfflib/docs/faq/): This page centralises common questions and answers about D'fflib, grouped per category.