SoC and the Apex Common Library Tutorial Series Part 17: Implementing Unit Tests with the Apex Mocks Library
| |

SoC and the Apex Common Library Tutorial Series Part 17: Implementing Unit Tests with the Apex Mocks Library

What is Apex Mocks? Apex Mocks is unit test mocking framework for Apex that was inspired by the very popular Java Mockito framework. The Apex Mocks framework is also built using Salesforce’s Stub API which is a good thing, there are mocking frameworks in existence that do not leverage the Stub API… you shouldn’t use…

SoC and the Apex Common Library Tutorial Series Part 16: Unit Test Mocks with Separation of Concerns
| |

SoC and the Apex Common Library Tutorial Series Part 16: Unit Test Mocks with Separation of Concerns

How does Unit Testing fit into Separation of Concerns? The answer to this is simple, without Separation of Concerns, there is no unit testing, it just simply isn’t possible. To unit test you need to be able to create stub (mock) classes to send into your class you are testing via dependency injection (or through…

SoC and the Apex Common Library Tutorial Series Part 15: The Difference Between Unit Tests and Integration Tests
| |

SoC and the Apex Common Library Tutorial Series Part 15: The Difference Between Unit Tests and Integration Tests

What is Unit Testing? Unit Testing, is a way to test the logic in one class and ONLY one class at a time. Most classes in your system at some point do one of the following: 1) Call to another class to get some work done. 2) Query the database directly in the class. 3)…

SoC and the Apex Common Library Tutorial Series Part 14: Implementing the Selector Layer with the Apex Common Library
| |

SoC and the Apex Common Library Tutorial Series Part 14: Implementing the Selector Layer with the Apex Common Library

The Template for every Selector Class you create Every Selector layer class you create should at least implement the following methods for it to work as anticipated. The fflib_SObjectSelector Constructor Parameters and what each of them mean When you create a Selector class that extends the fflib_SObjectSelector class you have the option to send some…

SoC and the Apex Common Library Tutorial Series Part 13: The Selector Layer
| |

SoC and the Apex Common Library Tutorial Series Part 13: The Selector Layer

What is the Selector Layer The Selector Layer is Salesforce is based off Martin Fowler’s Data Mapper Layer concept. It’s, “a layer of Mappers that moves data between objects and a database while keeping them independent of each other and the Mapper itself”. In most tech stacks when you want to represent records in a…

SoC and the Apex Common Library Tutorial Series Part 12: The Builder Pattern
| |

SoC and the Apex Common Library Tutorial Series Part 12: The Builder Pattern

What is the Builder Pattern? The Builder Pattern is a Creational Design Pattern that allows you to construct a complex object one step at a time. Think about the construction of a car or your house or maybe something less complicated, like the construction of a desktop computer. When you’re creating a new desktop computer…

SoC and the Apex Common Library Tutorial Series Part 11: Implementing The Domain Layer with the Apex Common Library
| |

SoC and the Apex Common Library Tutorial Series Part 11: Implementing The Domain Layer with the Apex Common Library

The template for every Domain Class you create Every Domain layer class you create for an object should at minimum have the following logic in it for it to work as expected. To understand why the Constructor inner class is necessary in these classes check out the triggerHandler method in the fflib_SObjectDomain class here: fflib_SObjectDomain…

SoC and the Apex Common Library Tutorial Series Part 10: The Domain Layer
| |

SoC and the Apex Common Library Tutorial Series Part 10: The Domain Layer

What is the Domain Layer? The Domain Layer is, “An object model of the domain that incorporates both behavior and data”. – Martin Fowler In most coding languages you need to connect to the database, query for the data and then you create wrapper classes to represent each underlying table in your database(s) to allow…

SoC and the Apex Common Library Tutorial Series Part 9: The Template Method Pattern
| |

SoC and the Apex Common Library Tutorial Series Part 9: The Template Method Pattern

What is the Template Method Pattern? The Template Method Pattern is one of the more popular Behavioral Design Pattern. The Template Design Pattern basically is creating a genericized skeleton class that a sub class can extend and add functionality to. The genericized skeleton class has some core functionality pre-built, but expects you to fill out…

SoC and the Apex Common Library Tutorial Series Part 8: Implementing the Service Layer with the Apex Common Library
| |

SoC and the Apex Common Library Tutorial Series Part 8: Implementing the Service Layer with the Apex Common Library

Preparation for the rest of this article There is NO FRAMEWORK that can be made for service layer classes. This is a business logic layer and it will differ everywhere. No two businesses are identical. That being said, if you would like to leverage all of the other benefits of the Apex Common Library (primarily…