SlideShare a Scribd company logo
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 Automation
Anna 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 DevOps
Sherry 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 ROI
DevOps 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 Software
DevOps 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 Success
TechWell
 
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 products
Shawn Doyle
 
Strategic Partnership for Rail IT Engagement
Strategic Partnership for Rail IT EngagementStrategic Partnership for Rail IT Engagement
Strategic Partnership for Rail IT Engagement
Tim 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 Costs
Jade 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 2017
Kari 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
 
Rational CLM at a glance
Rational CLM at a glanceRational CLM at a glance
Rational CLM at a glance
Prussian Eka Pradana
 
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 Tools
ghodgkinson
 

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 Cloud
Jeremy Likness
 
Open, Secure & Transparent AI Pipelines
Open, Secure & Transparent AI PipelinesOpen, Secure & Transparent AI Pipelines
Open, Secure & Transparent AI Pipelines
Nick Pentreath
 
Owasp summit slides day 2
Owasp summit slides day 2Owasp summit slides day 2
Owasp summit slides day 2
Dinis 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 Brisbane
Bejoy 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 implementation
mohamed 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 Saracevic
Agile ME
 
Software Testing in a Distributed Environment
Software Testing in a Distributed EnvironmentSoftware Testing in a Distributed Environment
Software Testing in a Distributed Environment
Perforce
 
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 Architectures
Brad Appleton
 
Agile Development – Why requirements matter
Agile Development – Why requirements matterAgile Development – Why requirements matter
Agile Development – Why requirements matter
Agile 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 Software
Steven Smith
 
Change Management in Hybrid landscapes 2017
Change Management in Hybrid landscapes 2017Change Management in Hybrid landscapes 2017
Change Management in Hybrid landscapes 2017
Chris Kernaghan
 
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
Feras Ahmad
 
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
mohamed refaei
 
Agile Development unleashed
Agile Development unleashedAgile Development unleashed
Agile Development unleashed
livgeni
 
The State of OpenStack Product Management
The State of OpenStack Product ManagementThe State of OpenStack Product Management
The State of OpenStack Product Management
Tesora
 
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
 
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
 
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
 
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 boston
BingWang77
 
Northeast Dreamin 2019
Northeast Dreamin 2019Northeast Dreamin 2019
Northeast Dreamin 2019
BingWang77
 
Salesforce Winter 20 interesting developer features
Salesforce Winter 20 interesting developer featuresSalesforce Winter 20 interesting developer features
Salesforce Winter 20 interesting developer features
BingWang77
 
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
BingWang77
 
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
BingWang77
 

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

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 

Recently uploaded (20)

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 

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!