Salesforce SoC and Apex Common Tutorial Series: Ep 3 - The Factory Pattern

preview_player
Показать описание
In this third episode of this tutorial series covering Separation of Concerns and the Apex Commons Library, I'm going to explain what the factory pattern is, why you would use it and how it fits into the apex common library and SoC.

Separation of Concerns Tutorial Series Order (Subject to Change):
Episode 1 - The Basics of Separation of Concerns
Episode 2 - Introduction to the Apex Common Library
Episode 3 - The Factory Pattern
Episode 4 - The fflib_Application Class
Episode 5 - The Unit of Work Pattern
Episode 6 - The fflib_SObjectUnitOfWork Class
Episode 7 - The Service Layer
Episode 8 - Implementing the Service Layer with the Apex Common Library
Episode 9 - The Template Method Pattern
Episode 10 - The Domain Layer
Episode 11 - Implementing the Domain Layer with the Apex Common Library
Episode 12 - The Builder Pattern
Episode 13 - The Selector Layer
Episode 14 - Implementing the Selector Layer with the Apex Common Library
Episode 15 - The Difference Between Unit Tests and Integration Tests
Episode 16 - Unit Testing and Separation of Concerns
Episode 17 - Implementing Unit Testing with Apex Mocks

Follow all of our social media here:

Salesforce development books I recommend:

Good Non-SF Specific Development Books:

-------------------------------------------------------------------------------------------------------------------------

Table of Contents:

0:00 - Intro
1:12 - Why use the Factory Pattern?
5:26 - Factory Pattern Example
21:42 - What is an Interface?
29:57 - Demoing our Factory Pattern Code
33:58 - Outro

DISCLAIMER: The views and ideas expressed on this YouTube channel and blog are based on past development experiences and may not always work for your particular scenarios. The advice in these videos may also become outdated as technology advances. They should be used as examples for educational purposes only. Using any shown solutions in your own org is not advisable since they are example scenarios.

#salesforce #salesforcedeveloper #salesforceadmin
Рекомендации по теме
Комментарии
Автор

It would have taken me weeks to understand this without your videos. Thank you for doing this.

jpateusa
Автор

Thanks for the contents! Indeed confusing, I will keep grinding my brains out until I get the grasps on it!

brmolinaa
Автор

Hi Matt

1. @17:38 an d @20:54 you say we can pass AccountObjecType but I really don't see where do we pass object type in your class. We are passing only the Ids. Also at @18:55 you mention we pass record Id's of type Case. How come Id is of a Case type, from my understanding ID is a simple type, like Guid or String and it doesn't contain any type information...

2. You don't seem to use anywhere in code parameter objectType in the method createTasks

3. Assuming that salesforce somehow is aware of what Type Id's are what would happen if you'd provide a set of ids of differet Type, like one for account one for contact and so on.. you receive only one domain

td
Автор

Hey man! That´s a great tutorial regarding on SOC! What if I wanted to create tasks based on Cases record types? For example, for one record type I would create a task with some information, and for other Case record type I would create a different task.
Where should I put this logic in? Is there a way to abstract this and find the record type dinamically as you did with sObject type? And what if I had many objects with many record types in it? Thanks for sharing knowlodge with us!

ferraracantor
Автор

hey, your example code link is not working

MISO
Автор

Hey there Matt. Thank you for this series.

I'm working my way through this series and I am trying to determine how best to implement this library in our org. The team I am on inherited a mess of an org. Since we came together as a team, ONE application has successfully implemented the common library and unlocked packages. However, we want to use the library in the rest of our code.

We do a LOT of customized code based validations and data flowing from opp down to the order and back up to the opp through a trigger factory framework. Also, we use Salesforce CPQ for quoting and are just now getting around to fully using CPQ ... it's a long story.

So my question is this (and I may be jumping way ahead): is the factory library easily adjusted for customized validation? Basically coding business rules for validating objects prior to inserting or updating.

ericolson
Автор

Hi Matt, for people with less knowledge in apex to have this library on our vs code, what should we do?

thevinin
Автор

Hi Matt, I've just recently started watching your videos (good job btw, it's hard to explain these concepts I feel) as a result of realizing - a bit too late - that I need to consider SoC for the codebase I've written. I'll be spending the rest of this month refactoring...
My only concern is that our org uses EDA which has something called table driven trigger management, which I've used. I don't know if you know much about the TDTM framework, but my concern is am I right to use these concepts within TDTM triggers? To what extent can I employ these techniques in my code? I'm really in the dark and would greatly appreciate any help.
Thanks again for the time you put into these videos. :)

hoven