such as in the ComplianceService example in the 2nd edition book Step 8 page 190, you will get a null pointer exception in inner class fflib_Application.DomainFactory, method newInstance(Set<Id> recordIds)
This is because the Domain factory depends on the Selector factory and as these are static variables, they are initialized in the order of appearance. If declared out of order, the SelectorFactory will be null for this use case.
As folks may populate the Application class from scratch; it is easy to overlook this declaration order dependency (ask me how I know!)
Suggestion: throw a more meaningful exception with a hint as to why this might be happening.
A minor point but worthy of an enhancement
If you define your Application class with Application.Domain before Application.Selector, when you attempt to use this construction:
such as in the ComplianceService example in the 2nd edition book Step 8 page 190, you will get a null pointer exception in inner class
fflib_Application.DomainFactory, method newInstance(Set<Id> recordIds)
This is because the Domain factory depends on the Selector factory and as these are static variables, they are initialized in the order of appearance. If declared out of order, the SelectorFactory will be null for this use case.
As folks may populate the Application class from scratch; it is easy to overlook this declaration order dependency (ask me how I know!)
Suggestion: throw a more meaningful exception with a hint as to why this might be happening.