Skip to content

wimvelzeboer/fflib-apex-common

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FFLib Apex Common 2.0

Build Status

Dependencies: Must deploy ApexMocks and Force-DI before deploying this library

Deploy to Salesforce

What's new in v2.0

This fork of fflib-apex-commons has some major changes to its architecture, while maintaining backwards compatible.

  • Event driven architecture
    Ability to publish custom events in Apex. Listeners will be invoked in realtime or can run as Queueable Apex. This feature will also replace the existing trigger handler (fflib_SObjectDomain).
  • Domain architecture
    Domain can now be constructed with generic Objects and not limited to SObjects. This allows the creation of compound domains, DTO's and more. Major improvement is the introduction of primitive domains.
  • Selector Architecture
    Added feature:
    • Fluent design for changing the following, directly from the calling method instead of in the selector class
      • ordering
      • limit
      • offset
  • Criteria based filtering for domain and selector
    The criteria class can be used to have one common filter for both selector and domain classes. Where the selector is querying its data for a source and the domain queries the data in memory from its own objects.
  • Application factories redesigned and can use Force-DI
    Redesign of interface structure of the Application class factories, in order to easily replace their implementation. Now force-di is fully integrated into the application while also maintaining backwards compatibility with the classic way of working with Maps. The force-di integration is just another implementation of the factories.

Road Map for fflib-apex-common v2.0

  • UnitOfWork redesign
    A more efficient unitOfWork, also able to process any kind of task and taking up less CPU time

  • Selector Architecture
    The selector will be redesigned to that its not coupled to a database. In this new architecture the selector will retrieve data from wherever it is stored. It should not be the concern of a service class calling the selector to know where the data is coming from.
    This new architecture should allow for getting the data from;

    • In memory from previous queries (Identity Map Design Pattern)
    • A Platform Cache
    • The Database
    • External WebService

    The queries should also be able to roll-over. Like when the requested record is not in memory, then the next selector in line should be called as the record might be in the Platform cache. If it is still not found the record can be queried from a database.

  • Queued Actions
    A replacement for the scheduled actions of process builder flows, as it is difficult to update flows with scheduled actions. This feature contains a queue object with actions and scheduled jobs to execute the actions when they are scheduled. Events are used to tell the application that the given action should be performed.

Updates

  • December 2020, IMPORTANT CHANGE, the repository had become dependent on force-di. If that is not desired, just exclude the folder sfdx-source/apex-common/classes/force-di.
  • April 2020, IMPORTANT CHANGE, the directory format of this project repo was converted to Salesforce DX Source Format. While the GIT commit history was maintained, it is not visible on GitHub. If you need to see the history, either clone the repo and execute git log --follow from the command line or refer to this tag of the codebase prior to conversion.
  • September 2014, IMPORTANT CHANGE, changes applied to support Dreamforce 2014 advanced presentation, library now provides Application factories for major layers and support for ApexMocks. More details to follow! As a result ApexMocks must be deployed to the org before deploying this library. The sample application here has also been updated to demonstrate the new features!
  • July 2014, IMPORTANT CHANGE, prior 23rd July 2014, both the fflib_SObjectDomain.onValidate() and fflib_SObjectDomain.onValidate(Map<Id, SObject> existingRecords) methods where called during an on after update trigger event. From this point on the onValidate() method will only be called during on after insert. If you still require the orignal behaviour add the line Configuration.enableOldOnUpdateValidateBehaviour(); into your constructor.
  • June 2014, New classes providing utilities to support security and dynamic queries, in addition to improvements to existing Apex Enterprise Pattern base classes. Read more here.
  • June 2014, Experimental branch supporting automated FLS checking, see README for more details.

This Library

Is derived from the Dreamforce 2012 presentation on Apex Enterprise Patterns and progresses the patterns further with a more general ongoing home for them. It also adds some form of namespace qualification from the previous version. So that classes are grouped together more easily in the IDE's and packages. Below you can find comprehensive articles and videos on the use of these patterns. There is also a working sample application illustrating the patterns here.

Alt text

Application Enterprise Patterns on Force.com

Design patterns are an invaluable tool for developers and architects looking to build enterprise solutions. Here are presented some tried and tested enterprise application engineering patterns that have been used in other platforms and languages. We will discuss and illustrate how patterns such as Data Mapper, Service Layer, Unit of Work and of course Model View Controller can be applied to Force.com. Applying these patterns can help manage governed resources (such as DML) better, encourage better separation-of-concerns in your logic and enforce Force.com coding best practices.

Dreamforce Session and Slides

  • View slides for the Dreamforce 2013 session here
  • Video recording of the Dreamforce 2013 session here.
  • Video recording of the Advanced Apex Enterprise Dreamforce 2014 session here.
  • View slides for the Dreamforce 2015 session here

Documentation

Other Related Blogs

About

Apex Enterprise Patterns 2.0, with lots of new architecture patterns and much more!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Apex 100.0%