├── Interface_Segregation_Principle_Example ├── TonsOfMethods.cls ├── MethodA_Interface.cls ├── MethodB_Interface.cls ├── kewlComponent │ ├── kewlComponent.html │ ├── kewlComponent.js-meta.xml │ └── kewlComponent.js ├── utilities_Service │ ├── utilities_Service.html │ ├── utilities_Service.js-meta.xml │ └── utilities_Service.js ├── ClassMethodACalls.cls ├── ClassB_Service.cls ├── ClassThatDependsOnAAndB.cls ├── ClassThatDependsOnA.cls ├── ClassThatDependsOnB.cls ├── ClassThatDependsOnC.cls ├── ClassA_Service.cls ├── ClassEverythingDependsOn.cls └── ClassE_Service.cls ├── Liskov_Substitution_Principle_Example ├── taskCreatorLWC │ ├── taskCreatorLWC.html │ ├── opportunityTaskCreator.js │ ├── taskCreator.js │ ├── taskCreatorLWC.js │ ├── contactTaskCreator.js │ └── taskCreatorLWC.js-meta.xml ├── TaskCreatorLSP_Interface.cls ├── TaskCreator_Service.cls ├── TaskCreator_Interface.cls ├── ContactTask_Service.cls └── OpportunityTaske_Service.cls ├── Open_Closed_Principle_Example ├── openClosedBadExample │ ├── openClosedBadExample.html │ ├── objectServiceLeadImpl.js │ ├── objectServiceContactImpl.js │ ├── objectServiceFactory.js │ ├── openClosedBadExample.js-meta.xml │ ├── openClosedBadExample.js │ └── objectService.js ├── lwcMap │ ├── lwcMap.html │ ├── lwcMap.js-meta.xml │ └── lwcMap.js ├── UIWrapper_Interface.cls ├── DisplayWrapper_Interface.cls ├── MapLocation.cls ├── MapMarker.cls ├── UIWrapperService.cls ├── OpenClosed_BadExample.cls ├── MapMarkerLead_Impl.cls └── MapMarkerContact_Impl.cls ├── Single_Responsibility_Principle_Example ├── OppCalculator_Interface.cls ├── srpExample │ ├── oppServiceCTO.js │ ├── oppServiceManager.js │ ├── srpExample.html │ ├── oppServiceFactory.js │ ├── srpExample.js │ ├── srpExample.js-meta.xml │ └── oppService.js ├── SingleResponsibilityPrinciple_Example.cls-meta.xml ├── OppCalculatorService_CTO.cls ├── OppCalculatorService_Managers.cls ├── OppCalculatorService_SalesAssoc.cls ├── OppCalculator_Controller.cls ├── OppCalculator_Service.cls └── OppCalculator_Combined_Service.cls ├── Dependency_Inversion_Principle_Example ├── srpExample │ ├── oppServiceCTO.js │ ├── oppServiceManager.js │ ├── srpExample.html │ ├── oppServiceFactory.js │ ├── srpExample.js │ ├── srpExample.js-meta.xml │ └── oppService.js ├── CaseClosure_Interface.cls ├── CaseClosureService_Interface.cls ├── CaseClosure_Controller.cls ├── CaseClosure_Service.cls ├── CaseClosure_Service_Delivery_Impl.cls └── CaseClosure_Service_Order_Impl.cls └── README.md /Interface_Segregation_Principle_Example/TonsOfMethods.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public interface TonsOfMethods 6 | { 7 | void methodC(); 8 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/MethodA_Interface.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public interface MethodA_Interface 6 | { 7 | void methodA(); 8 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/MethodB_Interface.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public interface MethodB_Interface 6 | { 7 | void methodB(); 8 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/kewlComponent/kewlComponent.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Liskov_Substitution_Principle_Example/taskCreatorLWC/taskCreatorLWC.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/utilities_Service/utilities_Service.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/openClosedBadExample/openClosedBadExample.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/OppCalculator_Interface.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | public interface OppCalculator_Interface 6 | { 7 | void calculateOpps(); 8 | } -------------------------------------------------------------------------------- /Liskov_Substitution_Principle_Example/taskCreatorLWC/opportunityTaskCreator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/9/2021. 3 | */ 4 | 5 | export class opportunityTaskCreator{ 6 | createTasks() { 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /Liskov_Substitution_Principle_Example/TaskCreatorLSP_Interface.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/9/2021. 3 | */ 4 | 5 | public interface TaskCreatorLSP_Interface 6 | { 7 | void createTasks(SObject record); 8 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/lwcMap/lwcMap.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/srpExample/oppServiceCTO.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | export class oppServiceCTO { 6 | calculateOpps(){ 7 | console.log('Opps for CTO'); 8 | } 9 | } -------------------------------------------------------------------------------- /Liskov_Substitution_Principle_Example/taskCreatorLWC/taskCreator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/9/2021. 3 | */ 4 | 5 | export class taskCreator { 6 | createTasks(){ 7 | console.log('tasks created'); 8 | } 9 | } -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/srpExample/oppServiceCTO.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | export class oppServiceCTO { 6 | calculateOpps(){ 7 | console.log('Opps for CTO'); 8 | } 9 | } -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/CaseClosure_Interface.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/30/2021. 3 | */ 4 | 5 | public interface CaseClosure_Interface 6 | { 7 | void determineIfCaseShouldClose(List cases); 8 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/openClosedBadExample/objectServiceLeadImpl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/31/2021. 3 | */ 4 | 5 | export class objectServiceLeadImpl { 6 | setMessage(){ 7 | return 'Im a Lead'; 8 | } 9 | } -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/srpExample/oppServiceManager.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | export class oppServiceManager { 6 | calculateOpps(){ 7 | console.log('Opps for Manager'); 8 | } 9 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/openClosedBadExample/objectServiceContactImpl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/31/2021. 3 | */ 4 | 5 | export class objectServiceContactImpl { 6 | setMessage(){ 7 | return 'Im a Contact'; 8 | } 9 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Salesforce SOLID Design Principles Tutorial Series 2 | This repo houses the code created in the Salesforce SOLID Design Principle Tutorial Series located here: https://www.youtube.com/playlist?list=PL0wESsiWMBTohLGsACdQaLFfjzNjeCuLh 3 | -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/srpExample/oppServiceManager.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | export class oppServiceManager { 6 | calculateOpps(){ 7 | console.log('Opps for Manager'); 8 | } 9 | } -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/CaseClosureService_Interface.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/30/2021. 3 | */ 4 | 5 | public interface CaseClosureService_Interface 6 | { 7 | void determineIfCaseShouldClose(List cases); 8 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/ClassMethodACalls.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public with sharing class ClassMethodACalls 6 | { 7 | public void kewlFunction(string taco){ 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /Liskov_Substitution_Principle_Example/taskCreatorLWC/taskCreatorLWC.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/9/2021. 3 | */ 4 | 5 | import {LightningElement} from 'lwc'; 6 | 7 | export default class TaskCreatorLwc extends LightningElement { 8 | 9 | } -------------------------------------------------------------------------------- /Liskov_Substitution_Principle_Example/TaskCreator_Service.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/9/2021. 3 | */ 4 | 5 | public with sharing class TaskCreator_Service 6 | { 7 | public static void createTask(SObject record){ 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/UIWrapper_Interface.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/30/2021. 3 | */ 4 | 5 | public interface UIWrapper_Interface 6 | { 7 | List getRecords(); 8 | List wrapRecordsForUI(List sObjectRecords); 9 | } -------------------------------------------------------------------------------- /Liskov_Substitution_Principle_Example/taskCreatorLWC/contactTaskCreator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/9/2021. 3 | */ 4 | import {taskCreator} from "./taskCreator"; 5 | 6 | export class contactTaskCreator{ 7 | createTasks() { 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/DisplayWrapper_Interface.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/31/2021. 3 | */ 4 | 5 | public interface DisplayWrapper_Interface 6 | { 7 | List getRecords(); 8 | List wrapRecordsForUI(List sObjectRecords); 9 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/MapLocation.cls: -------------------------------------------------------------------------------- 1 | public class MapLocation{ 2 | @AuraEnabled 3 | public String Street; 4 | @AuraEnabled 5 | public String City; 6 | @AuraEnabled 7 | public String Country; 8 | @AuraEnabled 9 | public String PostalCode; 10 | } -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/srpExample/srpExample.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/ClassB_Service.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public with sharing class ClassB_Service implements MethodB_Interface 6 | { 7 | public void methodB(){ 8 | System.debug('Method B Call'); 9 | } 10 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/ClassThatDependsOnAAndB.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public with sharing class ClassThatDependsOnAAndB 6 | { 7 | //calls method A in ClassE_Service 8 | 9 | //calls method B in ClassE_Service 10 | } -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/SingleResponsibilityPrinciple_Example.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 51.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/srpExample/srpExample.html: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/MapMarker.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/30/2021. 3 | */ 4 | 5 | public class MapMarker{ 6 | @AuraEnabled 7 | public MapLocation location; 8 | @AuraEnabled 9 | public String title; 10 | @AuraEnabled 11 | public String description; 12 | } -------------------------------------------------------------------------------- /Liskov_Substitution_Principle_Example/TaskCreator_Interface.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/9/2021. 3 | */ 4 | 5 | public interface TaskCreator_Interface 6 | { 7 | void createTaskOpportunity(Id whatIdRelationship, Opportunity opp); 8 | void createTaskContact(Id whatId, Contact cont); 9 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/ClassThatDependsOnA.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public with sharing class ClassThatDependsOnA 6 | { 7 | public void callMethodA(){ 8 | ClassA_Service megaClass = new ClassA_Service(); 9 | megaClass.methodA(); 10 | } 11 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/ClassThatDependsOnB.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public with sharing class ClassThatDependsOnB 6 | { 7 | public void callMethodB(){ 8 | ClassB_Service megaClass = new ClassB_Service(); 9 | megaClass.methodB(); 10 | } 11 | } -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/OppCalculatorService_CTO.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | public with sharing class OppCalculatorService_CTO implements OppCalculator_Interface 6 | { 7 | public void calculateOpps(){ 8 | System.debug('CTO Opps'); 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /Liskov_Substitution_Principle_Example/ContactTask_Service.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/9/2021. 3 | */ 4 | 5 | public with sharing class ContactTask_Service implements TaskCreatorLSP_Interface 6 | { 7 | public void createTasks(SObject record){ 8 | System.debug('Creating contact tasks'); 9 | } 10 | } -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/OppCalculatorService_Managers.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | public with sharing class OppCalculatorService_Managers implements OppCalculator_Interface 6 | { 7 | public void calculateOpps(){ 8 | System.debug('Manager Opps'); 9 | } 10 | } -------------------------------------------------------------------------------- /Liskov_Substitution_Principle_Example/OpportunityTaske_Service.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/9/2021. 3 | */ 4 | 5 | public with sharing class OpportunityTaske_Service implements TaskCreatorLSP_Interface 6 | { 7 | public void createTasks(SObject record){ 8 | System.debug('Creating opp tasks'); 9 | } 10 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/ClassThatDependsOnC.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public with sharing class ClassThatDependsOnC 6 | { 7 | public void callMethodC(){ 8 | ClassEverythingDependsOn megaClass = new ClassEverythingDependsOn(); 9 | megaClass.methodC(); 10 | } 11 | } -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/OppCalculatorService_SalesAssoc.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | public with sharing class OppCalculatorService_SalesAssoc implements OppCalculator_Interface 6 | { 7 | public void calculateOpps(){ 8 | System.debug('Sales Associate Opps'); 9 | } 10 | } -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/srpExample/oppServiceFactory.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | export class oppServiceFactory { 6 | classType; 7 | constructor(classType) { 8 | this.classType = classType 9 | } 10 | calculateOpps(){ 11 | this.classType.calculateOpps(); 12 | } 13 | } -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/OppCalculator_Controller.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | public with sharing class OppCalculator_Controller 6 | { 7 | @AuraEnabled 8 | public static void calculateOpps(String userType){ 9 | OppCalculator_Service.calculateOpps(userType); 10 | } 11 | } -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/srpExample/oppServiceFactory.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | export class oppServiceFactory { 6 | classType; 7 | constructor(classType) { 8 | this.classType = classType 9 | } 10 | calculateOpps(){ 11 | this.classType.calculateOpps(); 12 | } 13 | } -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/CaseClosure_Controller.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/30/2021. 3 | */ 4 | 5 | public with sharing class CaseClosure_Controller 6 | { 7 | @AuraEnabled 8 | public static void closeCase(Case cs){ 9 | CaseClosure_Service.determineIfCaseShouldClose(new List{cs}, 'Order'); 10 | } 11 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/openClosedBadExample/objectServiceFactory.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/31/2021. 3 | */ 4 | 5 | export class objectServiceFactory { 6 | classType; 7 | constructor(classType) { 8 | this.classType = classType; 9 | } 10 | setMessage(){ 11 | return this.classType.setMessage(); 12 | } 13 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/ClassA_Service.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public with sharing class ClassA_Service implements MethodA_Interface 6 | { 7 | public void methodA(){ 8 | ClassMethodACalls kewlClass = new ClassMethodACalls(); 9 | kewlClass.kewlFunction(); 10 | System.debug('Method A Call'); 11 | } 12 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/kewlComponent/kewlComponent.js-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 53.0 4 | Kewl Component 5 | false 6 | Kewl Component 7 | 8 | -------------------------------------------------------------------------------- /Liskov_Substitution_Principle_Example/taskCreatorLWC/taskCreatorLWC.js-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 53.0 4 | Task Creator Lwc 5 | false 6 | Task Creator Lwc 7 | 8 | -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/utilities_Service/utilities_Service.js-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 53.0 4 | Utilities Service 5 | false 6 | Utilities Service 7 | 8 | -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/openClosedBadExample/openClosedBadExample.js-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 51.0 4 | Open Closed Bad Example 5 | false 6 | Open Closed Bad Example 7 | 8 | -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/kewlComponent/kewlComponent.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | import {LightningElement} from 'lwc'; 6 | import {UtilitiesService} from "c/utilities_Service"; 7 | 8 | export default class KewlComponent extends LightningElement { 9 | 10 | connectedCallback() { 11 | const utils = new UtilitiesService(); 12 | utils.createToasts(); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/srpExample/srpExample.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | import {LightningElement} from 'lwc'; 6 | import {oppService} from "./oppService"; 7 | 8 | export default class SrpExample extends LightningElement { 9 | userType = 'Manager'; 10 | calculateOpps(){ 11 | const oppService1 = new oppService(); 12 | oppService1.calculateOpps(this.userType); 13 | } 14 | } -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/srpExample/srpExample.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | import {LightningElement} from 'lwc'; 6 | import {oppService} from "./oppService"; 7 | 8 | export default class SrpExample extends LightningElement { 9 | userType = 'Manager'; 10 | calculateOpps(){ 11 | const oppService1 = new oppService(); 12 | oppService1.calculateOpps(this.userType); 13 | } 14 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/lwcMap/lwcMap.js-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 51.0 4 | Lwc Map 5 | true 6 | Lwc Map 7 | 8 | lightning__RecordPage 9 | 10 | 11 | -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/srpExample/srpExample.js-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 51.0 4 | Srp Example 5 | true 6 | Srp Example 7 | 8 | 9 | lightning__RecordPage 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/srpExample/srpExample.js-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 51.0 4 | Srp Example 5 | true 6 | Srp Example 7 | 8 | 9 | lightning__RecordPage 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/utilities_Service/utilities_Service.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | export function createToasts(){ 6 | 7 | } 8 | 9 | export class ToastClass{ 10 | createToasts(){ 11 | 12 | } 13 | } 14 | 15 | 16 | export class UtilitiesService{ 17 | 18 | createToasts(){ 19 | 20 | } 21 | 22 | createErrorLog(){ 23 | 24 | } 25 | 26 | createConsoleLog(){ 27 | 28 | } 29 | 30 | popModal(){ 31 | console.log('popping modal'); 32 | } 33 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/ClassEverythingDependsOn.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public with sharing class ClassEverythingDependsOn implements TonsOfMethods 6 | { 7 | public void methodA(){ 8 | ClassMethodACalls kewlClass = new ClassMethodACalls(); 9 | kewlClass.kewlFunction(); 10 | System.debug('Method A Call'); 11 | } 12 | 13 | public void methodB(){ 14 | System.debug('Method B Call'); 15 | } 16 | 17 | public void methodC(){ 18 | System.debug('Method C Call'); 19 | } 20 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/openClosedBadExample/openClosedBadExample.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/31/2021. 3 | */ 4 | 5 | import {LightningElement, api} from 'lwc'; 6 | import {objectService} from "./objectService"; 7 | 8 | export default class OpenClosedBadExample extends LightningElement { 9 | @api objectApiName; 10 | message; 11 | connectedCallback() { 12 | this.getObjectMessage(); 13 | } 14 | 15 | getObjectMessage(){ 16 | const objectService = new objectService(); 17 | this.message = objectService.setMessage(this.objectApiName); 18 | } 19 | } -------------------------------------------------------------------------------- /Interface_Segregation_Principle_Example/ClassE_Service.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/16/2021. 3 | */ 4 | 5 | public with sharing class ClassE_Service implements MethodA_Interface, MethodB_Interface 6 | { 7 | public void methodA(){ 8 | Type methodAInterfaceType = Type.forName('ClassA_Service'); 9 | MethodA_Interface methodAInterface = 10 | (MethodA_Interface)methodAInterfaceType.newInstance(); 11 | methodAInterface.methodA(); 12 | } 13 | 14 | public void methodB(){ 15 | ClassB_Service classB = new ClassB_Service(); 16 | classB.methodB(); 17 | } 18 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/lwcMap/lwcMap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/30/2021. 3 | */ 4 | 5 | import {LightningElement, api} from 'lwc'; 6 | import getUIDataController from '@salesforce/apex/LWCMapController.getDataForUI'; 7 | 8 | export default class LwcMap extends LightningElement { 9 | @api objectApiName 10 | mapMarkers; 11 | 12 | connectedCallback() { 13 | this.getMapMarkers(); 14 | } 15 | 16 | getMapMarkers(){ 17 | getUIDataController({"objectApiName":"Contact", "uiType":"MapMarker"}).then(markers =>{ 18 | this.mapMarkers = markers; 19 | }); 20 | } 21 | } -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/srpExample/oppService.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | import {oppServiceCTO} from "./oppServiceCTO"; 5 | import {oppServiceManager} from "./oppServiceManager"; 6 | import {oppServiceFactory} from "./oppServiceFactory"; 7 | 8 | export class oppService { 9 | calculateOpps(userType){ 10 | let classType; 11 | if(userType === 'CTO'){ 12 | classType = new oppServiceCTO(); 13 | } 14 | else if (userType === 'Manager'){ 15 | classType = new oppServiceManager(); 16 | } 17 | const oppServiceFactory1 = new oppServiceFactory(classType); 18 | oppServiceFactory1.calculateOpps(); 19 | } 20 | } -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/srpExample/oppService.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | import {oppServiceCTO} from "./oppServiceCTO"; 5 | import {oppServiceManager} from "./oppServiceManager"; 6 | import {oppServiceFactory} from "./oppServiceFactory"; 7 | 8 | export class oppService { 9 | calculateOpps(userType){ 10 | let classType; 11 | if(userType === 'CTO'){ 12 | classType = new oppServiceCTO(); 13 | } 14 | else if (userType === 'Manager'){ 15 | classType = new oppServiceManager(); 16 | } 17 | const oppServiceFactory1 = new oppServiceFactory(classType); 18 | oppServiceFactory1.calculateOpps(); 19 | } 20 | } -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/OppCalculator_Service.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | public with sharing class OppCalculator_Service 6 | { 7 | private static Map userTypeToCalculatorImpl = new Map{ 8 | 'CTO' => OppCalculatorService_CTO.class, 9 | 'Sales Associate' => OppCalculatorService_SalesAssoc.class, 10 | 'Manager' => OppCalculatorService_Managers.class 11 | }; 12 | public static void calculateOpps(String userType){ 13 | OppCalculator_Interface oppCalculator = (OppCalculator_Interface)userTypeToCalculatorImpl.get(userType).newInstance(); 14 | oppCalculator.calculateOpps(); 15 | } 16 | } -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/CaseClosure_Service.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/30/2021. 3 | */ 4 | 5 | public with sharing class CaseClosure_Service 6 | { 7 | private static Map caseClosureServiceByRecordType = new Map{ 8 | 'Order' => CaseClosure_Service_Order_Impl.class, 9 | 'Delivery' => CaseClosure_Service_Delivery_Impl.class 10 | }; 11 | 12 | public static void determineIfCaseShouldClose(List cases, String recordTypeName){ 13 | CaseClosureService_Interface caseClosureService = 14 | (CaseClosureService_Interface)caseClosureServiceByRecordType.get(recordTypeName).newInstance(); 15 | caseClosureService.determineIfCaseShouldClose(cases); 16 | } 17 | } -------------------------------------------------------------------------------- /Single_Responsibility_Principle_Example/OppCalculator_Combined_Service.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/20/2021. 3 | */ 4 | 5 | public with sharing class OppCalculator_Combined_Service 6 | { 7 | public static void calculateOpps(String userType){ 8 | if(userType == 'CTO'){ 9 | calculateOppsCTO(); 10 | } 11 | else if(userType == 'Sales Associate'){ 12 | calculateOppsSales(); 13 | } 14 | else{ 15 | calculateOppsManager(); 16 | } 17 | } 18 | 19 | private static void calculateOppsCTO(){ 20 | System.debug('CTO Opps'); 21 | } 22 | 23 | private static void calculateOppsSales(){ 24 | System.debug('Sales Opps'); 25 | } 26 | 27 | private static void calculateOppsManager(){ 28 | System.debug('Manager Opps'); 29 | } 30 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/openClosedBadExample/objectService.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/31/2021. 3 | */ 4 | import {objectServiceContactImpl} from "./objectServiceContactImpl"; 5 | import {objectServiceLeadImpl} from "./objectServiceLeadImpl"; 6 | import {objectServiceFactory} from "./objectServiceFactory"; 7 | 8 | export class objectService { 9 | classType; 10 | setMessage(objectType){ 11 | if(this.objectApiName === 'Contact'){ 12 | this.classType = new objectServiceContactImpl(); 13 | } 14 | else if(this.objectApiName === 'Lead'){ 15 | this.classType = new objectServiceLeadImpl(); 16 | } 17 | const serviceFactory = new objectServiceFactory(this.classType); 18 | return serviceFactory.setMessage(); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/UIWrapperService.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/31/2021. 3 | */ 4 | 5 | public with sharing class UIWrapperService 6 | { 7 | private static Map objectAndUITypeToWrapperImpl = new Map{ 8 | 'ContactMapMarker' => MapMarkerContact_Impl.class, 9 | 'LeadMapMarker' => MapMarkerLead_Impl.class, 10 | 'CampaignMemberMapMarker' => 11 | }; 12 | public static List getRecords(String objectType, String uiType){ 13 | DisplayWrapper_Interface wrapperInterface = (DisplayWrapper_Interface)objectAndUITypeToWrapperImpl.get(objectType+uiType).newInstance(); 14 | return wrapperInterface.getRecords(); 15 | } 16 | public static List wrapRecordsForUI(List sObjectRecords, String uiType){ 17 | DisplayWrapper_Interface wrapperInterface = (DisplayWrapper_Interface)objectAndUITypeToWrapperImpl.get(sObjectRecords[0].getSObjectType() + '' + uiType).newInstance(); 18 | return wrapperInterface.wrapRecordsForUI(sObjectRecords); 19 | } 20 | } -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/CaseClosure_Service_Delivery_Impl.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/30/2021. 3 | */ 4 | 5 | public with sharing class CaseClosure_Service_Delivery_Impl implements CaseClosureService_Interface 6 | { 7 | public void determineIfCaseShouldClose(List cases){ 8 | System.debug('Calling Service Class'); 9 | List casesToClose = new List(); 10 | List casesToReject = new List(); 11 | for(Case cs: cases){ 12 | if(cs.Status == 'Delivered'){ 13 | casesToClose.add(cs); 14 | } 15 | else{ 16 | casesToReject.add(cs); 17 | } 18 | } 19 | rejectCaseClosure(casesToReject); 20 | closeCase(casesToClose); 21 | } 22 | 23 | private static void rejectCaseClosure(List casesToReject){ 24 | for(Case cs: casesToReject){ 25 | cs.Status = 'Redo Case'; 26 | } 27 | update casesToReject; 28 | } 29 | 30 | private static void closeCase(List casesToClose){ 31 | for(Case cs: casesToClose){ 32 | cs.Status = 'Closed - Delivered'; 33 | } 34 | update casesToClose; 35 | } 36 | } -------------------------------------------------------------------------------- /Dependency_Inversion_Principle_Example/CaseClosure_Service_Order_Impl.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 11/30/2021. 3 | */ 4 | 5 | public with sharing class CaseClosure_Service_Order_Impl implements CaseClosureService_Interface 6 | { 7 | public void determineIfCaseShouldClose(List cases){ 8 | System.debug('Calling Order Class'); 9 | List casesToClose = new List(); 10 | List casesToReject = new List(); 11 | for(Case cs: cases){ 12 | if(cs.Status == 'Resolved' || cs.Status == 'Tacoz'){ 13 | casesToClose.add(cs); 14 | } 15 | else{ 16 | casesToReject.add(cs); 17 | } 18 | } 19 | rejectCaseClosure(casesToReject); 20 | closeCase(casesToClose); 21 | } 22 | 23 | private static void rejectCaseClosure(List casesToReject){ 24 | for(Case cs: casesToReject){ 25 | cs.Status = 'Rejected'; 26 | } 27 | update casesToReject; 28 | } 29 | 30 | private static void closeCase(List casesToClose){ 31 | for(Case cs: casesToClose){ 32 | cs.Status = 'Closed'; 33 | } 34 | update casesToClose; 35 | } 36 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/OpenClosed_BadExample.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/30/2021. 3 | */ 4 | 5 | public with sharing class OpenClosed_BadExample 6 | { 7 | @AuraEnabled 8 | public static List getLeadsForMap(String objectName){ 9 | if(objectName == 'Lead') 10 | { 11 | List leadsInSystem = [ 12 | SELECT Id, FirstName, LastName, LeadSource, City, Street, PostalCode, Country FROM Lead WHERE Street != NULL AND PostalCode != NULL AND City != NULL AND Country != NULL 13 | ]; 14 | List mapMarkers = new List(); 15 | for(Lead ld : leadsInSystem) 16 | { 17 | MapMarker marker = new MapMarker(); 18 | MapLocation location = new MapLocation(); 19 | location.Country = ld.Country; 20 | location.City = ld.City; 21 | location.PostalCode = ld.PostalCode; 22 | location.Street = ld.Street; 23 | marker.location = location; 24 | marker.description = 'Hi'; 25 | marker.title = 'Jambette'; 26 | mapMarkers.add(marker); 27 | } 28 | System.debug(mapMarkers); 29 | return mapMarkers; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/MapMarkerLead_Impl.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/31/2021. 3 | */ 4 | 5 | public with sharing class MapMarkerLead_Impl implements DisplayWrapper_Interface 6 | { 7 | public List getRecords(){ 8 | List leadRecords = [SELECT Id, State, PostalCode, Country, City, Name, Street, Description FROM Lead 9 | WHERE City != null AND Country != null AND PostalCode != null AND State != null AND Street != null]; 10 | return leadRecords; 11 | } 12 | 13 | public List wrapRecordsForUI(List sObjectRecords){ 14 | List mapMarkers = new List(); 15 | for(Lead leadRecord: (List)sObjectRecords){ 16 | MapMarker marker = new MapMarker(); 17 | MapLocation mapLocation = new MapLocation(); 18 | mapLocation.Country = leadRecord.Country; 19 | mapLocation.PostalCode = leadRecord.PostalCode; 20 | mapLocation.Street = leadRecord.Street; 21 | mapLocation.City = leadRecord.City; 22 | marker.location = mapLocation; 23 | marker.title = leadRecord.Name; 24 | marker.description = leadRecord.Description; 25 | mapMarkers.add(marker); 26 | } 27 | return mapMarkers; 28 | } 29 | } -------------------------------------------------------------------------------- /Open_Closed_Principle_Example/MapMarkerContact_Impl.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by gerry on 10/31/2021. 3 | */ 4 | 5 | public with sharing class MapMarkerContact_Impl implements DisplayWrapper_Interface 6 | { 7 | public List getRecords(){ 8 | List contactRecords = [SELECT Id, MailingState, MailingPostalCode, MailingCountry, MailingCity, MailingStreet, Name, Description FROM Contact 9 | WHERE MailingCity != null AND MailingCountry != null AND MailingPostalCode != null AND MailingState != null AND MailingStreet != null]; 10 | return contactRecords; 11 | } 12 | 13 | public List wrapRecordsForUI(List sObjectRecords){ 14 | List mapMarkers = new List(); 15 | for(Contact cont: (List)sObjectRecords){ 16 | MapMarker marker = new MapMarker(); 17 | MapLocation mapLocation = new MapLocation(); 18 | mapLocation.Country = cont.MailingCountry; 19 | mapLocation.PostalCode = cont.MailingPostalCode; 20 | mapLocation.Street = cont.MailingStreet; 21 | mapLocation.City = cont.MailingCity; 22 | marker.location = mapLocation; 23 | marker.title = cont.Name; 24 | marker.description = cont.Description; 25 | mapMarkers.add(marker); 26 | } 27 | return mapMarkers; 28 | } 29 | } --------------------------------------------------------------------------------