SlideShare a Scribd company logo
1 of 32
Download to read offline
1
Apex
Enterprise
Patterns
Galore!
Boston Salesforce Developers Group
Marty Chang, Solution Architect – Slalom
Peter Yao, Senior Director, Products – BlueWave Solar
June 27, 2019
2
Agenda • Welcome!
• Why are we here?
• Best Practices & Demos
o Triggers, DML, Tests
o Controllers (LWC, Aura, VF) & SOQL
o Callouts
o Batchable & Schedulable jobs
• Takeaways
June 2019 Boston Salesforce Dev Group Meeting
3
Welcome!
4
Slalom is a modern consulting firm
focused on strategy, technology, and
business transformation.
Slalom is a modern consulting firm
focused on strategy, technology, and
business transformation.
5
strategy
Redefine what’s possible
Go beyond the expected. We help you move confidently through
ambiguity and risk, focus on your customer needs, and deliver
sustainable business value.
technology
We analyze, architect, and co-create
Learn from your data, create incredible digital experiences, or make
the most of new tech. We blend design, engineering, and analytics
expertise to help you build the future.
transformation
We deliver with you
New technologies. Shifting customers. Industry disruption. Business
moves fast, and we specialize in working through change with you.
Whatwedo
We bring impactful customer
experiences to life quickly
2,250+
Salesforce certifications
949
Projects for 318
clients in 2018
600+
Consultants with
Salesforce
experience
Platinum Consulting Partner
2x Partner Innovation Award Winner
Sales Cloud
Service Cloud
Community Cloud
Analytics Cloud
Einstein
Field Service
Marketing Cloud
Configure, Price, Quote (CPQ)
MuleSoft
Competencies
6
We believe in a world in which every
person loves their work and life.
We put
people first.
7
We are a B Corp on a mission to revolutionize energy with
simple, powerful solar solutions.
8
WHAT WE DO
88
HOME SOLAR LOANS COMMUNITY SOLAR SOLAR DEVELOPMENT
Improves solar financing
accessibility for
households with
viable rooftops.
Expands access to solar
for residents and small
businesses, regardless of
roof viability.
Provides environmental
and economic value by
developing large scale
community solar arrays.
9
Why are we
here?
June 2019 Boston Salesforce Dev Group Meeting
10
Several new developers introduced to the
team
Big classes, especially tests
Distinct user stories require updating the
same class resulting in merge conflicts
Most business logic initiated by trigger
Frequent encounters with governor limits
Duplicated code
Ø Where to start development?
Ø How to identify bug root cause?
A typical
problem
• Lines of code:
• 75k in .cls
• 12k in .cmp
• 12k in .js
• 4k in .page
• 500 in .trigger
June 2019 Boston Salesforce Dev Group Meeting
11
Separation of Concerns
Base Size of
Solution or Code
Number of
Developers
Requirements Scope Number of Client Types & Interactions SOC
Appropriate?
Small 1 to 2 •Well known and unlikely to change
•One-off solutions
•Limited number of objects
•Standard UI
•Simple UI / Triggers
•No Batch Mode
•No API
•No Mobile
Typically not
Small to Medium 1 to 6 •Well known but may need to evolve rapidly
•Growing number of objects and processing interactions
•Product deliverable or larger duration projects
•Standard UI
•Advanced VF / Lightning
•Batch Mode
•API (on roadmap)
•Mobile (on roadmap)
Worth
considering
Large > 6 •Scope driven by multiple customer and user types
•Large number of objects
•Generic product or solution aimed at Mid to Enterprise
market with Customer or Partner integrations
•Growing development team!
•Standard UI
•Advanced VF / Lightning
•Batch Mode
•Developer / Partner API
•Mobile Clients
•New Platform Feature Ready, Chatter Actions!
Definite benefits
https://trailhead.salesforce.com/en/content/learn/modules/apex_patterns_sl/apex_patterns_sl_soc
June 2019 Boston Salesforce Dev Group Meeting
12
12
Financial Force Apex Common: https://github.com/financialforcedev/fflib-apex-common/
Well Documented:
Actively discussed:
WHAT WE LIKED
Actively updated:
13
13
WHAT WE DIDN’T LIKE
Heavyweight:
Hard for us to use it all from the start, especially ApexMocks
The light-version fork is a few years old:
14
Performing SOQL and DML in
tests is expensive … and adds to
the overall time it takes to execute
all application tests, which
becomes important once you start
to consider Continuous
Integration.
Andrew Fawcett
Author of Force.com Enterprise Architecture
15
Build with unit tests in mind
June 2019 Boston Salesforce Dev Group Meeting
Considerations
• Salesforce requires code coverage for all Apex.
• 100% code coverage is a byproduct of well written tests.
• Unit tests are a first-order concern.
Responsibilities
• Every Apex class should have a corresponding test class.
• Mocks should be used to ensure that unit tests in a test class
only exercise the functions and methods within the
associated class.
• Integration tests should ideally exist separately from unit
tests, to reduce the time to run local tests for CI/CD.
16
What if triggers looked more like workflow rules?
Trigger “workflows”
June 2019 Boston Salesforce Dev Group Meeting
Considerations
• Trigger context variables are only available in the context of
a running DML operation.
• Recursion can get messy, across triggers, workflow rules
and Lightning processes (i.e., processes created with
Lightning Process Builder).
Responsibilities
• Evaluate entry criteria.
• Execute actions.
• Keep Trigger context variable references exclusively in
.trigger files.
17
Workflow Concept Trigger Workflow Concept
Object TriggerWorkflow__mdt.SobjectName__c
Rule Name Apex class name ending with Workflow
Description Apex class comment block
Evaluate the rule when a record is "created" or
"created, and every time it's edited"
TriggerWorkflow__mdt.IsOnInsert__c and
TriggerWorkflow__mdt.IsOnUpdate__c
Evaluate the rule when a record is "created, and
any time it's edited to subsequently meet criteria"
TriggerWorkflow__mdt.IsOnInsert__c and
TriggerWorkflow__mdt.IsOnUpdate__c with
custom logic in the workflow's qualify method
Rule Criteria Custom logic in the workflow's qualify method
Active TriggerWorkflow__mdt.IsActive__c
Workflow Actions
executeBefore() and executeAfter()
methods in the workflow class
18
19
Trigger Workflow
20
Why not have a “DJ” in your org harmonizing your data?
DatabaseJockey
June 2019 Boston Salesforce Dev Group Meeting
Considerations
• Reduce time to run local tests by minimizing the number of
Apex tests which execute DML operations.
Responsibilities
• Insert, update, delete, undelete SObject records.
• Be the only Apex class which performs DML operations.
21
22
23
24
25
26
27
28
Just an interface between the user and all available services
Controllers (LWC, Aura, VF)
June 2019 Boston Salesforce Dev Group Meeting
Considerations
• Different options for returning errors to the end-user
• Sharing (CRUD, FLS, record-level) is not enforced by default
• (VF) May need to maintain state of the end-user application
Responsibilities
• Call a single Service class to execute business logic
• Manage anything specific to the client or user interface
• Error handling
• Enforcing sharing
• If simple enough, replace with Lightning Data Service (or
Visualforce Remote Objects)
29
One query to rule them all (no matter where called from)
SOQL
June 2019 Boston Salesforce Dev Group Meeting
Considerations
• Introduces dependency on database fields & objects
• Records queried may be shared in different functions, with
different data populated
• By default, sharing (CRUD, FLS, record-level) is based on the
running user
Responsibilities
• Provide a predictable set of fields and order of records returned
• Ensure data is queried only when necessary (aka once)
• Control access to related object fields using wrapper classes
30
Share your services or take advantage of others’
Callouts (Inbound & Outbound)
June 2019 Boston Salesforce Dev Group Meeting
Considerations
• Security for accessing the endpoint and the data returned
• Versioning & backwards compatibility
• Order of operations with DML
Responsibilities
• Abstract callouts in separate classes to avoid tight dependencies
• Isolate external-facing Apex REST classes from the Service classes
they delegate to
• Handle exceptions and error messages appropriately
31
Takeaways
June 2019 Boston Salesforce Dev Group Meeting
• You don’t have to start from scratch.
• Establish a pattern and stick with it.
• Expect your pattern to change.
• Expect inconsistencies in your code base as your patterns
continue to evolve over time.
• Even if it’s by yourself, create a style guide and think about it
as you go. You can have plenty of interesting conversations
with your past self and your future self!
32
Thank you!

More Related Content

What's hot

TLC2018 Thomas Haver: Transform with Enterprise Automation
TLC2018 Thomas Haver: Transform with Enterprise AutomationTLC2018 Thomas Haver: Transform with Enterprise Automation
TLC2018 Thomas Haver: Transform with Enterprise AutomationAnna Royzman
 
Software Factory Tools Partner Day Final
Software Factory Tools Partner Day FinalSoftware Factory Tools Partner Day Final
Software Factory Tools Partner Day FinalLek Pongpatimet
 
Evolving Team Structure in DevOps
Evolving Team Structure in DevOpsEvolving Team Structure in DevOps
Evolving Team Structure in DevOpsSherry Chang
 
Microsoft ALM Platform Overview
Microsoft ALM Platform OverviewMicrosoft ALM Platform Overview
Microsoft ALM Platform OverviewSteve Lange
 
What’s new in Rational collaborative lifecycle management 2011?
What’s new in Rational collaborative lifecycle management 2011?What’s new in Rational collaborative lifecycle management 2011?
What’s new in Rational collaborative lifecycle management 2011?IBM Danmark
 
Quantifying DevOps Adoption Empirically for Demonstrable ROI
Quantifying DevOps Adoption Empirically for Demonstrable ROIQuantifying DevOps Adoption Empirically for Demonstrable ROI
Quantifying DevOps Adoption Empirically for Demonstrable ROIDevOps for Enterprise Systems
 
Lessons Learned from Large Scale Adoption of DevOps for IBM z Systems Software
Lessons Learned from Large Scale Adoption of DevOps for IBM z Systems SoftwareLessons Learned from Large Scale Adoption of DevOps for IBM z Systems Software
Lessons Learned from Large Scale Adoption of DevOps for IBM z Systems SoftwareDevOps for Enterprise Systems
 
Automation Culture: Essential to Agile Success
Automation Culture: Essential to Agile SuccessAutomation Culture: Essential to Agile Success
Automation Culture: Essential to Agile SuccessTechWell
 
M-Files Enterprise Content Management Software
M-Files Enterprise Content Management SoftwareM-Files Enterprise Content Management Software
M-Files Enterprise Content Management SoftwareChris Davidson
 
Establishing a service factory
Establishing a service factoryEstablishing a service factory
Establishing a service factorydavemayo
 
What are IBM Rational's CLM products
What are IBM Rational's CLM productsWhat are IBM Rational's CLM products
What are IBM Rational's CLM productsShawn Doyle
 
Strategic Partnership for Rail IT Engagement
Strategic Partnership for Rail IT EngagementStrategic Partnership for Rail IT Engagement
Strategic Partnership for Rail IT EngagementTim Groenwals
 
Eliminate up to 70% of Your Test Automation Costs
Eliminate up to 70% of Your Test Automation CostsEliminate up to 70% of Your Test Automation Costs
Eliminate up to 70% of Your Test Automation CostsJade Global
 
Xenon: Jade Automation Solution Automation | Testing Tools | Agile Test Autom...
Xenon: Jade Automation Solution Automation | Testing Tools | Agile Test Autom...Xenon: Jade Automation Solution Automation | Testing Tools | Agile Test Autom...
Xenon: Jade Automation Solution Automation | Testing Tools | Agile Test Autom...Jade Global
 
Exploratory Testing Kari Kakkonen BTD 2017
Exploratory Testing Kari Kakkonen BTD 2017Exploratory Testing Kari Kakkonen BTD 2017
Exploratory Testing Kari Kakkonen BTD 2017Kari Kakkonen
 
Overview and Demonstration of Dimensions CM 14.2 (FUG presentation track 2)
Overview and Demonstration of Dimensions CM 14.2 (FUG presentation track 2)Overview and Demonstration of Dimensions CM 14.2 (FUG presentation track 2)
Overview and Demonstration of Dimensions CM 14.2 (FUG presentation track 2)Serena Software
 
Pilot essentials webinar
Pilot essentials webinarPilot essentials webinar
Pilot essentials webinarMaarga Systems
 
A Software Factory Integrating Rational & WebSphere Tools
A Software Factory Integrating Rational & WebSphere ToolsA Software Factory Integrating Rational & WebSphere Tools
A Software Factory Integrating Rational & WebSphere Toolsghodgkinson
 

What's hot (20)

TLC2018 Thomas Haver: Transform with Enterprise Automation
TLC2018 Thomas Haver: Transform with Enterprise AutomationTLC2018 Thomas Haver: Transform with Enterprise Automation
TLC2018 Thomas Haver: Transform with Enterprise Automation
 
Software Factory Tools Partner Day Final
Software Factory Tools Partner Day FinalSoftware Factory Tools Partner Day Final
Software Factory Tools Partner Day Final
 
Evolving Team Structure in DevOps
Evolving Team Structure in DevOpsEvolving Team Structure in DevOps
Evolving Team Structure in DevOps
 
Microsoft ALM Platform Overview
Microsoft ALM Platform OverviewMicrosoft ALM Platform Overview
Microsoft ALM Platform Overview
 
What’s new in Rational collaborative lifecycle management 2011?
What’s new in Rational collaborative lifecycle management 2011?What’s new in Rational collaborative lifecycle management 2011?
What’s new in Rational collaborative lifecycle management 2011?
 
Quantifying DevOps Adoption Empirically for Demonstrable ROI
Quantifying DevOps Adoption Empirically for Demonstrable ROIQuantifying DevOps Adoption Empirically for Demonstrable ROI
Quantifying DevOps Adoption Empirically for Demonstrable ROI
 
Lessons Learned from Large Scale Adoption of DevOps for IBM z Systems Software
Lessons Learned from Large Scale Adoption of DevOps for IBM z Systems SoftwareLessons Learned from Large Scale Adoption of DevOps for IBM z Systems Software
Lessons Learned from Large Scale Adoption of DevOps for IBM z Systems Software
 
Automation Culture: Essential to Agile Success
Automation Culture: Essential to Agile SuccessAutomation Culture: Essential to Agile Success
Automation Culture: Essential to Agile Success
 
M-Files Enterprise Content Management Software
M-Files Enterprise Content Management SoftwareM-Files Enterprise Content Management Software
M-Files Enterprise Content Management Software
 
Establishing a service factory
Establishing a service factoryEstablishing a service factory
Establishing a service factory
 
What are IBM Rational's CLM products
What are IBM Rational's CLM productsWhat are IBM Rational's CLM products
What are IBM Rational's CLM products
 
Strategic Partnership for Rail IT Engagement
Strategic Partnership for Rail IT EngagementStrategic Partnership for Rail IT Engagement
Strategic Partnership for Rail IT Engagement
 
Eliminate up to 70% of Your Test Automation Costs
Eliminate up to 70% of Your Test Automation CostsEliminate up to 70% of Your Test Automation Costs
Eliminate up to 70% of Your Test Automation Costs
 
Xenon: Jade Automation Solution Automation | Testing Tools | Agile Test Autom...
Xenon: Jade Automation Solution Automation | Testing Tools | Agile Test Autom...Xenon: Jade Automation Solution Automation | Testing Tools | Agile Test Autom...
Xenon: Jade Automation Solution Automation | Testing Tools | Agile Test Autom...
 
Bala_Kalimuthu
Bala_KalimuthuBala_Kalimuthu
Bala_Kalimuthu
 
Exploratory Testing Kari Kakkonen BTD 2017
Exploratory Testing Kari Kakkonen BTD 2017Exploratory Testing Kari Kakkonen BTD 2017
Exploratory Testing Kari Kakkonen BTD 2017
 
Overview and Demonstration of Dimensions CM 14.2 (FUG presentation track 2)
Overview and Demonstration of Dimensions CM 14.2 (FUG presentation track 2)Overview and Demonstration of Dimensions CM 14.2 (FUG presentation track 2)
Overview and Demonstration of Dimensions CM 14.2 (FUG presentation track 2)
 
Rational CLM at a glance
Rational CLM at a glanceRational CLM at a glance
Rational CLM at a glance
 
Pilot essentials webinar
Pilot essentials webinarPilot essentials webinar
Pilot essentials webinar
 
A Software Factory Integrating Rational & WebSphere Tools
A Software Factory Integrating Rational & WebSphere ToolsA Software Factory Integrating Rational & WebSphere Tools
A Software Factory Integrating Rational & WebSphere Tools
 

Similar to Apex Enterprise Patterns Galore - Boston, MA dev group meeting 062719

ALM with TFS: From the Drawing Board to the Cloud
ALM with TFS: From the Drawing Board to the CloudALM with TFS: From the Drawing Board to the Cloud
ALM with TFS: From the Drawing Board to the CloudJeremy Likness
 
Open, Secure & Transparent AI Pipelines
Open, Secure & Transparent AI PipelinesOpen, Secure & Transparent AI Pipelines
Open, Secure & Transparent AI PipelinesNick Pentreath
 
Owasp summit slides day 2
Owasp summit slides day 2Owasp summit slides day 2
Owasp summit slides day 2Dinis Cruz
 
Cloud Applications SCM20181111.pptxOATUG MEMBERS SHARE THE VALUE OF THEIR MEM...
Cloud Applications SCM20181111.pptxOATUG MEMBERS SHARE THE VALUE OF THEIR MEM...Cloud Applications SCM20181111.pptxOATUG MEMBERS SHARE THE VALUE OF THEIR MEM...
Cloud Applications SCM20181111.pptxOATUG MEMBERS SHARE THE VALUE OF THEIR MEM...BobBullman
 
Scaling Agile - Bejoy Jaison - Keynote at Agile and DevOps Conference Brisbane
Scaling Agile - Bejoy Jaison - Keynote at Agile and DevOps Conference BrisbaneScaling Agile - Bejoy Jaison - Keynote at Agile and DevOps Conference Brisbane
Scaling Agile - Bejoy Jaison - Keynote at Agile and DevOps Conference BrisbaneBejoy Jaison
 
Best practices for fusion hcm cloud implementation
Best practices for fusion hcm cloud implementationBest practices for fusion hcm cloud implementation
Best practices for fusion hcm cloud implementationmohamed refaei
 
Agile Development – Why requirements matter by Fariz Saracevic
Agile Development – Why requirements matter by Fariz SaracevicAgile Development – Why requirements matter by Fariz Saracevic
Agile Development – Why requirements matter by Fariz SaracevicAgile ME
 
Software Testing in a Distributed Environment
Software Testing in a Distributed EnvironmentSoftware Testing in a Distributed Environment
Software Testing in a Distributed EnvironmentPerforce
 
Just the Job: Employing Solr for Recruitment Search -Charlie Hull
Just the Job: Employing Solr for Recruitment Search -Charlie Hull Just the Job: Employing Solr for Recruitment Search -Charlie Hull
Just the Job: Employing Solr for Recruitment Search -Charlie Hull lucenerevolution
 
SCM Patterns for Agile Architectures
SCM Patterns for Agile ArchitecturesSCM Patterns for Agile Architectures
SCM Patterns for Agile ArchitecturesBrad Appleton
 
Agile Development – Why requirements matter
Agile Development – Why requirements matterAgile Development – Why requirements matter
Agile Development – Why requirements matterAgile Austria Conference
 
An intro to building an architecture repository meta model and modeling frame...
An intro to building an architecture repository meta model and modeling frame...An intro to building an architecture repository meta model and modeling frame...
An intro to building an architecture repository meta model and modeling frame...wweinmeyer79
 
Improving The Quality of Existing Software
Improving The Quality of Existing SoftwareImproving The Quality of Existing Software
Improving The Quality of Existing SoftwareSteven Smith
 
Change Management in Hybrid landscapes 2017
Change Management in Hybrid landscapes 2017Change Management in Hybrid landscapes 2017
Change Management in Hybrid landscapes 2017Chris Kernaghan
 
20 best practices for fusion hcm cloud implementation
20   best practices for fusion hcm cloud implementation20   best practices for fusion hcm cloud implementation
20 best practices for fusion hcm cloud implementationmohamed refaei
 
Best practices for fusion hcm cloud implementation
Best practices for fusion hcm cloud implementationBest practices for fusion hcm cloud implementation
Best practices for fusion hcm cloud implementationFeras Ahmad
 
Agile Development unleashed
Agile Development unleashedAgile Development unleashed
Agile Development unleashedlivgeni
 
The State of OpenStack Product Management
The State of OpenStack Product ManagementThe State of OpenStack Product Management
The State of OpenStack Product ManagementTesora
 
Microservices at Scale: How to Reduce Overhead and Increase Developer Product...
Microservices at Scale: How to Reduce Overhead and Increase Developer Product...Microservices at Scale: How to Reduce Overhead and Increase Developer Product...
Microservices at Scale: How to Reduce Overhead and Increase Developer Product...DevOps.com
 

Similar to Apex Enterprise Patterns Galore - Boston, MA dev group meeting 062719 (20)

ALM with TFS: From the Drawing Board to the Cloud
ALM with TFS: From the Drawing Board to the CloudALM with TFS: From the Drawing Board to the Cloud
ALM with TFS: From the Drawing Board to the Cloud
 
Open, Secure & Transparent AI Pipelines
Open, Secure & Transparent AI PipelinesOpen, Secure & Transparent AI Pipelines
Open, Secure & Transparent AI Pipelines
 
Owasp summit slides day 2
Owasp summit slides day 2Owasp summit slides day 2
Owasp summit slides day 2
 
Cloud Applications SCM20181111.pptxOATUG MEMBERS SHARE THE VALUE OF THEIR MEM...
Cloud Applications SCM20181111.pptxOATUG MEMBERS SHARE THE VALUE OF THEIR MEM...Cloud Applications SCM20181111.pptxOATUG MEMBERS SHARE THE VALUE OF THEIR MEM...
Cloud Applications SCM20181111.pptxOATUG MEMBERS SHARE THE VALUE OF THEIR MEM...
 
Scaling Agile - Bejoy Jaison - Keynote at Agile and DevOps Conference Brisbane
Scaling Agile - Bejoy Jaison - Keynote at Agile and DevOps Conference BrisbaneScaling Agile - Bejoy Jaison - Keynote at Agile and DevOps Conference Brisbane
Scaling Agile - Bejoy Jaison - Keynote at Agile and DevOps Conference Brisbane
 
Best practices for fusion hcm cloud implementation
Best practices for fusion hcm cloud implementationBest practices for fusion hcm cloud implementation
Best practices for fusion hcm cloud implementation
 
Agile Development – Why requirements matter by Fariz Saracevic
Agile Development – Why requirements matter by Fariz SaracevicAgile Development – Why requirements matter by Fariz Saracevic
Agile Development – Why requirements matter by Fariz Saracevic
 
Software Testing in a Distributed Environment
Software Testing in a Distributed EnvironmentSoftware Testing in a Distributed Environment
Software Testing in a Distributed Environment
 
Just the Job: Employing Solr for Recruitment Search -Charlie Hull
Just the Job: Employing Solr for Recruitment Search -Charlie Hull Just the Job: Employing Solr for Recruitment Search -Charlie Hull
Just the Job: Employing Solr for Recruitment Search -Charlie Hull
 
Vikas Kumar
Vikas KumarVikas Kumar
Vikas Kumar
 
SCM Patterns for Agile Architectures
SCM Patterns for Agile ArchitecturesSCM Patterns for Agile Architectures
SCM Patterns for Agile Architectures
 
Agile Development – Why requirements matter
Agile Development – Why requirements matterAgile Development – Why requirements matter
Agile Development – Why requirements matter
 
An intro to building an architecture repository meta model and modeling frame...
An intro to building an architecture repository meta model and modeling frame...An intro to building an architecture repository meta model and modeling frame...
An intro to building an architecture repository meta model and modeling frame...
 
Improving The Quality of Existing Software
Improving The Quality of Existing SoftwareImproving The Quality of Existing Software
Improving The Quality of Existing Software
 
Change Management in Hybrid landscapes 2017
Change Management in Hybrid landscapes 2017Change Management in Hybrid landscapes 2017
Change Management in Hybrid landscapes 2017
 
20 best practices for fusion hcm cloud implementation
20   best practices for fusion hcm cloud implementation20   best practices for fusion hcm cloud implementation
20 best practices for fusion hcm cloud implementation
 
Best practices for fusion hcm cloud implementation
Best practices for fusion hcm cloud implementationBest practices for fusion hcm cloud implementation
Best practices for fusion hcm cloud implementation
 
Agile Development unleashed
Agile Development unleashedAgile Development unleashed
Agile Development unleashed
 
The State of OpenStack Product Management
The State of OpenStack Product ManagementThe State of OpenStack Product Management
The State of OpenStack Product Management
 
Microservices at Scale: How to Reduce Overhead and Increase Developer Product...
Microservices at Scale: How to Reduce Overhead and Increase Developer Product...Microservices at Scale: How to Reduce Overhead and Increase Developer Product...
Microservices at Scale: How to Reduce Overhead and Increase Developer Product...
 

More from BingWang77

Beyond layouts
Beyond layouts Beyond layouts
Beyond layouts BingWang77
 
Dreamforce 19 global gathering boston
Dreamforce 19 global gathering   bostonDreamforce 19 global gathering   boston
Dreamforce 19 global gathering bostonBingWang77
 
Northeast Dreamin 2019
Northeast Dreamin 2019Northeast Dreamin 2019
Northeast Dreamin 2019BingWang77
 
Salesforce Winter 20 interesting developer features
Salesforce Winter 20 interesting developer featuresSalesforce Winter 20 interesting developer features
Salesforce Winter 20 interesting developer featuresBingWang77
 
Spring and Summer '19 Development Feature Highlights
Spring and Summer '19 Development Feature HighlightsSpring and Summer '19 Development Feature Highlights
Spring and Summer '19 Development Feature HighlightsBingWang77
 
Boston, MA Developer Group 2/7/2019 - Introduction to lightning web components
Boston, MA Developer Group 2/7/2019 - Introduction to lightning web componentsBoston, MA Developer Group 2/7/2019 - Introduction to lightning web components
Boston, MA Developer Group 2/7/2019 - Introduction to lightning web componentsBingWang77
 

More from BingWang77 (6)

Beyond layouts
Beyond layouts Beyond layouts
Beyond layouts
 
Dreamforce 19 global gathering boston
Dreamforce 19 global gathering   bostonDreamforce 19 global gathering   boston
Dreamforce 19 global gathering boston
 
Northeast Dreamin 2019
Northeast Dreamin 2019Northeast Dreamin 2019
Northeast Dreamin 2019
 
Salesforce Winter 20 interesting developer features
Salesforce Winter 20 interesting developer featuresSalesforce Winter 20 interesting developer features
Salesforce Winter 20 interesting developer features
 
Spring and Summer '19 Development Feature Highlights
Spring and Summer '19 Development Feature HighlightsSpring and Summer '19 Development Feature Highlights
Spring and Summer '19 Development Feature Highlights
 
Boston, MA Developer Group 2/7/2019 - Introduction to lightning web components
Boston, MA Developer Group 2/7/2019 - Introduction to lightning web componentsBoston, MA Developer Group 2/7/2019 - Introduction to lightning web components
Boston, MA Developer Group 2/7/2019 - Introduction to lightning web components
 

Recently uploaded

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyAnusha Are
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 

Recently uploaded (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 

Apex Enterprise Patterns Galore - Boston, MA dev group meeting 062719

  • 1. 1 Apex Enterprise Patterns Galore! Boston Salesforce Developers Group Marty Chang, Solution Architect – Slalom Peter Yao, Senior Director, Products – BlueWave Solar June 27, 2019
  • 2. 2 Agenda • Welcome! • Why are we here? • Best Practices & Demos o Triggers, DML, Tests o Controllers (LWC, Aura, VF) & SOQL o Callouts o Batchable & Schedulable jobs • Takeaways June 2019 Boston Salesforce Dev Group Meeting
  • 4. 4 Slalom is a modern consulting firm focused on strategy, technology, and business transformation. Slalom is a modern consulting firm focused on strategy, technology, and business transformation.
  • 5. 5 strategy Redefine what’s possible Go beyond the expected. We help you move confidently through ambiguity and risk, focus on your customer needs, and deliver sustainable business value. technology We analyze, architect, and co-create Learn from your data, create incredible digital experiences, or make the most of new tech. We blend design, engineering, and analytics expertise to help you build the future. transformation We deliver with you New technologies. Shifting customers. Industry disruption. Business moves fast, and we specialize in working through change with you. Whatwedo We bring impactful customer experiences to life quickly 2,250+ Salesforce certifications 949 Projects for 318 clients in 2018 600+ Consultants with Salesforce experience Platinum Consulting Partner 2x Partner Innovation Award Winner Sales Cloud Service Cloud Community Cloud Analytics Cloud Einstein Field Service Marketing Cloud Configure, Price, Quote (CPQ) MuleSoft Competencies
  • 6. 6 We believe in a world in which every person loves their work and life. We put people first.
  • 7. 7 We are a B Corp on a mission to revolutionize energy with simple, powerful solar solutions.
  • 8. 8 WHAT WE DO 88 HOME SOLAR LOANS COMMUNITY SOLAR SOLAR DEVELOPMENT Improves solar financing accessibility for households with viable rooftops. Expands access to solar for residents and small businesses, regardless of roof viability. Provides environmental and economic value by developing large scale community solar arrays.
  • 9. 9 Why are we here? June 2019 Boston Salesforce Dev Group Meeting
  • 10. 10 Several new developers introduced to the team Big classes, especially tests Distinct user stories require updating the same class resulting in merge conflicts Most business logic initiated by trigger Frequent encounters with governor limits Duplicated code Ø Where to start development? Ø How to identify bug root cause? A typical problem • Lines of code: • 75k in .cls • 12k in .cmp • 12k in .js • 4k in .page • 500 in .trigger June 2019 Boston Salesforce Dev Group Meeting
  • 11. 11 Separation of Concerns Base Size of Solution or Code Number of Developers Requirements Scope Number of Client Types & Interactions SOC Appropriate? Small 1 to 2 •Well known and unlikely to change •One-off solutions •Limited number of objects •Standard UI •Simple UI / Triggers •No Batch Mode •No API •No Mobile Typically not Small to Medium 1 to 6 •Well known but may need to evolve rapidly •Growing number of objects and processing interactions •Product deliverable or larger duration projects •Standard UI •Advanced VF / Lightning •Batch Mode •API (on roadmap) •Mobile (on roadmap) Worth considering Large > 6 •Scope driven by multiple customer and user types •Large number of objects •Generic product or solution aimed at Mid to Enterprise market with Customer or Partner integrations •Growing development team! •Standard UI •Advanced VF / Lightning •Batch Mode •Developer / Partner API •Mobile Clients •New Platform Feature Ready, Chatter Actions! Definite benefits https://trailhead.salesforce.com/en/content/learn/modules/apex_patterns_sl/apex_patterns_sl_soc June 2019 Boston Salesforce Dev Group Meeting
  • 12. 12 12 Financial Force Apex Common: https://github.com/financialforcedev/fflib-apex-common/ Well Documented: Actively discussed: WHAT WE LIKED Actively updated:
  • 13. 13 13 WHAT WE DIDN’T LIKE Heavyweight: Hard for us to use it all from the start, especially ApexMocks The light-version fork is a few years old:
  • 14. 14 Performing SOQL and DML in tests is expensive … and adds to the overall time it takes to execute all application tests, which becomes important once you start to consider Continuous Integration. Andrew Fawcett Author of Force.com Enterprise Architecture
  • 15. 15 Build with unit tests in mind June 2019 Boston Salesforce Dev Group Meeting Considerations • Salesforce requires code coverage for all Apex. • 100% code coverage is a byproduct of well written tests. • Unit tests are a first-order concern. Responsibilities • Every Apex class should have a corresponding test class. • Mocks should be used to ensure that unit tests in a test class only exercise the functions and methods within the associated class. • Integration tests should ideally exist separately from unit tests, to reduce the time to run local tests for CI/CD.
  • 16. 16 What if triggers looked more like workflow rules? Trigger “workflows” June 2019 Boston Salesforce Dev Group Meeting Considerations • Trigger context variables are only available in the context of a running DML operation. • Recursion can get messy, across triggers, workflow rules and Lightning processes (i.e., processes created with Lightning Process Builder). Responsibilities • Evaluate entry criteria. • Execute actions. • Keep Trigger context variable references exclusively in .trigger files.
  • 17. 17 Workflow Concept Trigger Workflow Concept Object TriggerWorkflow__mdt.SobjectName__c Rule Name Apex class name ending with Workflow Description Apex class comment block Evaluate the rule when a record is "created" or "created, and every time it's edited" TriggerWorkflow__mdt.IsOnInsert__c and TriggerWorkflow__mdt.IsOnUpdate__c Evaluate the rule when a record is "created, and any time it's edited to subsequently meet criteria" TriggerWorkflow__mdt.IsOnInsert__c and TriggerWorkflow__mdt.IsOnUpdate__c with custom logic in the workflow's qualify method Rule Criteria Custom logic in the workflow's qualify method Active TriggerWorkflow__mdt.IsActive__c Workflow Actions executeBefore() and executeAfter() methods in the workflow class
  • 18. 18
  • 20. 20 Why not have a “DJ” in your org harmonizing your data? DatabaseJockey June 2019 Boston Salesforce Dev Group Meeting Considerations • Reduce time to run local tests by minimizing the number of Apex tests which execute DML operations. Responsibilities • Insert, update, delete, undelete SObject records. • Be the only Apex class which performs DML operations.
  • 21. 21
  • 22. 22
  • 23. 23
  • 24. 24
  • 25. 25
  • 26. 26
  • 27. 27
  • 28. 28 Just an interface between the user and all available services Controllers (LWC, Aura, VF) June 2019 Boston Salesforce Dev Group Meeting Considerations • Different options for returning errors to the end-user • Sharing (CRUD, FLS, record-level) is not enforced by default • (VF) May need to maintain state of the end-user application Responsibilities • Call a single Service class to execute business logic • Manage anything specific to the client or user interface • Error handling • Enforcing sharing • If simple enough, replace with Lightning Data Service (or Visualforce Remote Objects)
  • 29. 29 One query to rule them all (no matter where called from) SOQL June 2019 Boston Salesforce Dev Group Meeting Considerations • Introduces dependency on database fields & objects • Records queried may be shared in different functions, with different data populated • By default, sharing (CRUD, FLS, record-level) is based on the running user Responsibilities • Provide a predictable set of fields and order of records returned • Ensure data is queried only when necessary (aka once) • Control access to related object fields using wrapper classes
  • 30. 30 Share your services or take advantage of others’ Callouts (Inbound & Outbound) June 2019 Boston Salesforce Dev Group Meeting Considerations • Security for accessing the endpoint and the data returned • Versioning & backwards compatibility • Order of operations with DML Responsibilities • Abstract callouts in separate classes to avoid tight dependencies • Isolate external-facing Apex REST classes from the Service classes they delegate to • Handle exceptions and error messages appropriately
  • 31. 31 Takeaways June 2019 Boston Salesforce Dev Group Meeting • You don’t have to start from scratch. • Establish a pattern and stick with it. • Expect your pattern to change. • Expect inconsistencies in your code base as your patterns continue to evolve over time. • Even if it’s by yourself, create a style guide and think about it as you go. You can have plenty of interesting conversations with your past self and your future self!