Andy in the Cloud

From BBC Basic to Force.com and beyond…

Preview : Apex Enterprise Patterns – Domain Layer

3 Comments

I’ve been busy writing the next article in my series on Apex Enterprise Patterns. This weekend I completed the draft for review before submitting to Force.com. Its the biggest article yet, with over three and half thousand words. And an update to the Dreamforce 2012 sample code to support some additional OO and test aspects I wanted to highlight.

The following is a sneak preview of the upcoming article. Also if your interested in taking a look at some of the updated sample code you’ll find this in the Github repo here. Enjoy!

Domain Model, “An object model of the domain that incorporates both behavior and data.”, “At its worst business logic can be very complex. Rules and logic describe many different cases and slants of behavior, and it’s this complexity that objects were designed to work with…” Martin Fowler, EAA Patterns

Who uses the Domain layer?

There are two ways in which “Domain layer logic” is invoked.

  • Database Manipulation. CRUD operations, or more specifically Create, Update and Delete operations, occur on your Custom Objects. As users or tools interact via the standard Salesforce UI or via one of the platforms API’s. These can be routed to the appropriate Domain class code corresponding to that object and operation.

  • Service Operations. The Service layer implementations should be easily able to identify and reuse code relating to one or more of the objects each of its operations interact with via Domain classes. This also helps keep the code in the service layer focused on orchestrating whatever business process or task its exposing.

This diagram brings together the Service Layer and Domain Layer patterns and how they interact with each other as well other aspects of the application architecture.

Screen Shot 2013-04-07 at 12.21.32

To be continued on developer.force.com….

3 thoughts on “Preview : Apex Enterprise Patterns – Domain Layer

  1. Truly awesome stuff. Can’t tell you how much your work has impacted my own design patterns. Thanks much, can’t wait to see the full article and now I’m off to review the newest revisions in the repo – and learn a few more things.

    • Thanks Bo, great feedback, the draft for the next article will be heading over to the developer.force.com editor tomorrow, not quite sure of the timescales he has in mind for final publication after that, but hopefully won’t be to much longer.

      In the meantime, it would be good to touch base and learn a bit more about what you’ve been doing if you where up for that? We could work on a blog post together (your blog or mine not fussed) showing the patterns in use (in some abstract or altered use case form of course)? Let me know, absolutely no pressure. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s