SlideShare a Scribd company logo
Apex Development Best Practices
http://bit.ly/sf1-dev-bp
Sebastian Wagner, @tquiladotcom, Technical Architect
@seb__wagner
“I cannot teach anybody anything,
I can only make them think”
Socrates
Agenda
 Principles
 Process
 Development
– Conventions
– Queries
– Loops
– Tests
 QA
Process
 track requirements
 separate development sandboxes
 use source control (git, Mercury, SVN)
 automate deployment with CI
 iterate
Requirements
 Understand
– What is expected?
– Why, what are the drivers?
 Think
– How to implement?
– Impact, Dependencies
 Challenge
– Can it be flexed, to match platform features?
Platform Advantages
 Config over Code
– workflows instead of triggers
– Page Layout vs. Visualforce
 Native over Custom
– standard instead of custom objects
– re-label field
 Install/Deploy over Build
– AppExchange
– Github
XP Principles
 MVP - Minimum Viable Product (80/20 rule)
– focus on the core features
 KISS - Keep It Simple & Stupid
– the simplest solution to meet the requirement
– easy to use, read and change. looks simple
 DRY – Don’t Repeat Yourself
– Components, Labels, Templates, Abstraction, Service Classes
 YAGNI – You Arent Gonna Need It
– implement only WHEN you actually need it
DEV – Structure
The structure of code and config is clear and
understandable
 be consistent
 use a naming convention
 self describing names
 declare constants and literal values in variable or config
DEV – Comments
Loops and more complex parts of the algorithms are clear
and commented
 clear code (what) over comments (why)
 provide context and help understanding
 describe purpose of classes and methods
 do NOT comment trivial code
DEV – Error Handling
Exceptions and errors are managed using
exception handling
 catch in user facing code (e.g. in trigger or controller)
 provide useful description if necessary
 descriptive error messages
 do NOT catch exceptions in service methods,
unless you return your own error object
DEV – Error Handling
 insert Account Deactivation Handler
 https://gist.github.com/sebwagner/5e556d492fa2cc010d
c9
Query - Conditions
All SOQL queries are appropriately restricted by a WHERE
clause or a LIMIT parameter
 filter records by SOQL rather than code
 use of indexes (Id, Text, Number) whenever possible
 follows best practices for Query Optimizer (e.g. avoid to
filter on NULL)
Query - Conditions
Query – Efficiency
Efficient use of queries for good performance
 cache records for re-use in context
 avoid querying the same object multiple times
 exclude fields that are not needed
 lazy load Blob and Large Text fields
Query – Efficiency
Loops - Limits
Beware of the Governor Limits
 loops (for, do-while) do NOT invoke
– SOSL/SOQL statements
– DML statements
 method calls which use limits are not invoked in loops
where avoidable e.g. Describes, Callouts, sendEmail()
Loops - Limits
Testing – Code Coverage
Code coverage is no lower than 90%. yet it is not
everything, but
 high coverage => less bugs => less frustration
 keep testability in mind when writing code, because
 if you can’t test it, it's an indicator for Code Smell
Testing – Code Coverage ‘Alternative’
Testing – Test Data
Tests setup their own test data
@isTest(seeAllData=false)
 do NOT rely on organization data
 if org data is need, limit to methods
 use test data classes or methods for re-use
Testing – Test Data
Testing – Test Data
Testing - Assertions
Assertions are used to validate expected results
 true testing, validation rather than only execution
 +1 assert per test method
 use the message parameter to provide context
system.assert(Object,Object,message);
Testing - Assertions
Testing - Scenarios
Tests validate positive and negative outcomes
 Positive: execution with valid data / params
 Negative: execution with invalid data / params
 use system.runAs() to test
– Dynamic Apex
– Methods using with sharing or without sharing
– Shared records
Testing - Scenarios
Testing – Bulk Tests
Code should be bulkified, so should be the tests
 ensures you don’t hit governor limits
 can uncover performance bottlenecks
Testing – Bulk Tests
Thank you
http://bit.ly/sf1-dev-bp
Sebastian Wagner, @tquiladotcom, Technical Architect
@seb__wagner
Ad

More Related Content

What's hot (20)

Release Management: Managing Your Internal Releases
Release Management: Managing Your Internal ReleasesRelease Management: Managing Your Internal Releases
Release Management: Managing Your Internal Releases
Joshua Hoskins
 
5 Essentials for Simplifiied Release Management and Continuous Delivery
5 Essentials for Simplifiied Release Management and Continuous Delivery5 Essentials for Simplifiied Release Management and Continuous Delivery
5 Essentials for Simplifiied Release Management and Continuous Delivery
Salesforce Developers
 
Under the Hood of Sandbox Templates
Under the Hood of Sandbox TemplatesUnder the Hood of Sandbox Templates
Under the Hood of Sandbox Templates
Salesforce Developers
 
Design patterns for salesforce app decomposition
Design patterns for salesforce app decompositionDesign patterns for salesforce app decomposition
Design patterns for salesforce app decomposition
Sai Jithesh ☁️
 
Introduction to Apex Triggers
Introduction to Apex TriggersIntroduction to Apex Triggers
Introduction to Apex Triggers
Salesforce Developers
 
Follow the evidence: Troubleshooting Performance Issues
Follow the evidence:  Troubleshooting Performance IssuesFollow the evidence:  Troubleshooting Performance Issues
Follow the evidence: Troubleshooting Performance Issues
Salesforce Developers
 
How Open Source Embiggens Salesforce.com
How Open Source Embiggens Salesforce.comHow Open Source Embiggens Salesforce.com
How Open Source Embiggens Salesforce.com
Salesforce Engineering
 
Dev ops.enterprise.2014 (1)
Dev ops.enterprise.2014 (1)Dev ops.enterprise.2014 (1)
Dev ops.enterprise.2014 (1)
Salesforce Engineering
 
Salesforce Lightning Process builder
Salesforce Lightning Process builderSalesforce Lightning Process builder
Salesforce Lightning Process builder
Thinqloud
 
Managing Change With A Sensible Sandbox Architecture
Managing Change With A Sensible Sandbox ArchitectureManaging Change With A Sensible Sandbox Architecture
Managing Change With A Sensible Sandbox Architecture
Alexander Sutherland
 
Testing Web Apps and APIs (1)
Testing Web Apps and APIs (1)Testing Web Apps and APIs (1)
Testing Web Apps and APIs (1)
AAron EvaNS
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automation
Macharla Pradeep
 
Salesforce.com Sandbox management
Salesforce.com Sandbox management Salesforce.com Sandbox management
Salesforce.com Sandbox management
Ali Akbar
 
Salesforce1 ELEVATE Workshop - Dublin
Salesforce1 ELEVATE Workshop - DublinSalesforce1 ELEVATE Workshop - Dublin
Salesforce1 ELEVATE Workshop - Dublin
Joshua Hoskins
 
TDX19 - Accelerate DevOps with GitLab and Salesforce
TDX19 - Accelerate DevOps with GitLab and SalesforceTDX19 - Accelerate DevOps with GitLab and Salesforce
TDX19 - Accelerate DevOps with GitLab and Salesforce
Doug Ayers
 
Manage Development in Your Org with Salesforce Governance Framework
Manage Development in Your Org with Salesforce Governance FrameworkManage Development in Your Org with Salesforce Governance Framework
Manage Development in Your Org with Salesforce Governance Framework
Salesforce Developers
 
FSL Implementation Guidance Part 1
FSL Implementation Guidance Part 1FSL Implementation Guidance Part 1
FSL Implementation Guidance Part 1
Salesforce Partners
 
Discover salesforce, dev ops and Copado CI/CD automations
Discover salesforce, dev ops and Copado CI/CD automationsDiscover salesforce, dev ops and Copado CI/CD automations
Discover salesforce, dev ops and Copado CI/CD automations
JackGuo20
 
Salesforce Release Management - Best Practices and Tools for Deployment
Salesforce Release Management - Best Practices and Tools for DeploymentSalesforce Release Management - Best Practices and Tools for Deployment
Salesforce Release Management - Best Practices and Tools for Deployment
Salesforce Developers
 
WHAT ABOUT QA
WHAT ABOUT QAWHAT ABOUT QA
WHAT ABOUT QA
Chuck Summers
 
Release Management: Managing Your Internal Releases
Release Management: Managing Your Internal ReleasesRelease Management: Managing Your Internal Releases
Release Management: Managing Your Internal Releases
Joshua Hoskins
 
5 Essentials for Simplifiied Release Management and Continuous Delivery
5 Essentials for Simplifiied Release Management and Continuous Delivery5 Essentials for Simplifiied Release Management and Continuous Delivery
5 Essentials for Simplifiied Release Management and Continuous Delivery
Salesforce Developers
 
Design patterns for salesforce app decomposition
Design patterns for salesforce app decompositionDesign patterns for salesforce app decomposition
Design patterns for salesforce app decomposition
Sai Jithesh ☁️
 
Follow the evidence: Troubleshooting Performance Issues
Follow the evidence:  Troubleshooting Performance IssuesFollow the evidence:  Troubleshooting Performance Issues
Follow the evidence: Troubleshooting Performance Issues
Salesforce Developers
 
How Open Source Embiggens Salesforce.com
How Open Source Embiggens Salesforce.comHow Open Source Embiggens Salesforce.com
How Open Source Embiggens Salesforce.com
Salesforce Engineering
 
Salesforce Lightning Process builder
Salesforce Lightning Process builderSalesforce Lightning Process builder
Salesforce Lightning Process builder
Thinqloud
 
Managing Change With A Sensible Sandbox Architecture
Managing Change With A Sensible Sandbox ArchitectureManaging Change With A Sensible Sandbox Architecture
Managing Change With A Sensible Sandbox Architecture
Alexander Sutherland
 
Testing Web Apps and APIs (1)
Testing Web Apps and APIs (1)Testing Web Apps and APIs (1)
Testing Web Apps and APIs (1)
AAron EvaNS
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automation
Macharla Pradeep
 
Salesforce.com Sandbox management
Salesforce.com Sandbox management Salesforce.com Sandbox management
Salesforce.com Sandbox management
Ali Akbar
 
Salesforce1 ELEVATE Workshop - Dublin
Salesforce1 ELEVATE Workshop - DublinSalesforce1 ELEVATE Workshop - Dublin
Salesforce1 ELEVATE Workshop - Dublin
Joshua Hoskins
 
TDX19 - Accelerate DevOps with GitLab and Salesforce
TDX19 - Accelerate DevOps with GitLab and SalesforceTDX19 - Accelerate DevOps with GitLab and Salesforce
TDX19 - Accelerate DevOps with GitLab and Salesforce
Doug Ayers
 
Manage Development in Your Org with Salesforce Governance Framework
Manage Development in Your Org with Salesforce Governance FrameworkManage Development in Your Org with Salesforce Governance Framework
Manage Development in Your Org with Salesforce Governance Framework
Salesforce Developers
 
FSL Implementation Guidance Part 1
FSL Implementation Guidance Part 1FSL Implementation Guidance Part 1
FSL Implementation Guidance Part 1
Salesforce Partners
 
Discover salesforce, dev ops and Copado CI/CD automations
Discover salesforce, dev ops and Copado CI/CD automationsDiscover salesforce, dev ops and Copado CI/CD automations
Discover salesforce, dev ops and Copado CI/CD automations
JackGuo20
 
Salesforce Release Management - Best Practices and Tools for Deployment
Salesforce Release Management - Best Practices and Tools for DeploymentSalesforce Release Management - Best Practices and Tools for Deployment
Salesforce Release Management - Best Practices and Tools for Deployment
Salesforce Developers
 

Viewers also liked (8)

Rails Admin - Guru SP
Rails Admin - Guru SPRails Admin - Guru SP
Rails Admin - Guru SP
Fabio Akita
 
RailsAdmin - the right way of doing data administration with Rails 3
RailsAdmin - the right way of doing data administration with Rails 3RailsAdmin - the right way of doing data administration with Rails 3
RailsAdmin - the right way of doing data administration with Rails 3
Bogdan Gaza
 
10 Techniques for Gathering Requirements
10 Techniques for Gathering Requirements10 Techniques for Gathering Requirements
10 Techniques for Gathering Requirements
z-999
 
Automating Deployment Between Orgs Using Git & Continuous Integration
Automating Deployment Between Orgs Using Git & Continuous IntegrationAutomating Deployment Between Orgs Using Git & Continuous Integration
Automating Deployment Between Orgs Using Git & Continuous Integration
Sebastian Wagner
 
Visualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for MobileVisualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for Mobile
Salesforce Developers
 
RailsAdmin - Overview and Best practices
RailsAdmin - Overview and Best practicesRailsAdmin - Overview and Best practices
RailsAdmin - Overview and Best practices
Benoit Bénézech
 
Using Visualforce in Salesforce1
Using Visualforce in Salesforce1Using Visualforce in Salesforce1
Using Visualforce in Salesforce1
Salesforce Developers
 
Structured Approach to Solution Architecture
Structured Approach to Solution ArchitectureStructured Approach to Solution Architecture
Structured Approach to Solution Architecture
Alan McSweeney
 
Rails Admin - Guru SP
Rails Admin - Guru SPRails Admin - Guru SP
Rails Admin - Guru SP
Fabio Akita
 
RailsAdmin - the right way of doing data administration with Rails 3
RailsAdmin - the right way of doing data administration with Rails 3RailsAdmin - the right way of doing data administration with Rails 3
RailsAdmin - the right way of doing data administration with Rails 3
Bogdan Gaza
 
10 Techniques for Gathering Requirements
10 Techniques for Gathering Requirements10 Techniques for Gathering Requirements
10 Techniques for Gathering Requirements
z-999
 
Automating Deployment Between Orgs Using Git & Continuous Integration
Automating Deployment Between Orgs Using Git & Continuous IntegrationAutomating Deployment Between Orgs Using Git & Continuous Integration
Automating Deployment Between Orgs Using Git & Continuous Integration
Sebastian Wagner
 
Visualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for MobileVisualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for Mobile
Salesforce Developers
 
RailsAdmin - Overview and Best practices
RailsAdmin - Overview and Best practicesRailsAdmin - Overview and Best practices
RailsAdmin - Overview and Best practices
Benoit Bénézech
 
Structured Approach to Solution Architecture
Structured Approach to Solution ArchitectureStructured Approach to Solution Architecture
Structured Approach to Solution Architecture
Alan McSweeney
 
Ad

Similar to SF1 - Apex Development Best Practises (20)

Software Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails ApplicationsSoftware Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails Applications
Bhavin Javia
 
Automation testing
Automation testingAutomation testing
Automation testing
Tomy Rhymond
 
Python - code quality and production monitoring
Python - code quality and production monitoringPython - code quality and production monitoring
Python - code quality and production monitoring
David Melamed
 
Hands-on Experience Model based testing with spec explorer
Hands-on Experience Model based testing with spec explorer Hands-on Experience Model based testing with spec explorer
Hands-on Experience Model based testing with spec explorer
Rachid Kherrazi
 
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
Alessandro Alpi
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
Alex Borsuk
 
XML2Selenium Technical Presentation
XML2Selenium Technical PresentationXML2Selenium Technical Presentation
XML2Selenium Technical Presentation
jazzteam
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applications
Chandra Sekhar Saripaka
 
Agile testing
Agile testingAgile testing
Agile testing
Raj Indugula
 
SQL Server Integration Services and Analysis Services
SQL Server Integration Services and Analysis ServicesSQL Server Integration Services and Analysis Services
SQL Server Integration Services and Analysis Services
Mohan Arumugam
 
Rachid kherrazi-testing-asd-interface-compliance-with-asd spec
Rachid kherrazi-testing-asd-interface-compliance-with-asd specRachid kherrazi-testing-asd-interface-compliance-with-asd spec
Rachid kherrazi-testing-asd-interface-compliance-with-asd spec
Rachid Kherrazi
 
Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test
Gregory Solovey
 
Parallel run selenium tests in a good way
Parallel run selenium tests in a good  wayParallel run selenium tests in a good  way
Parallel run selenium tests in a good way
COMAQA.BY
 
Best practice adoption (and lack there of)
Best practice adoption (and lack there of)Best practice adoption (and lack there of)
Best practice adoption (and lack there of)
John Pape
 
Testing 101
Testing 101Testing 101
Testing 101
Noam Barkai
 
Software Testing: Application And Script Independent Automation Framework: Th...
Software Testing: Application And Script Independent Automation Framework: Th...Software Testing: Application And Script Independent Automation Framework: Th...
Software Testing: Application And Script Independent Automation Framework: Th...
guest0efb5e
 
Automated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsAutomated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra Solutions
Quontra Solutions
 
No Devops Without Continuous Testing
No Devops Without Continuous TestingNo Devops Without Continuous Testing
No Devops Without Continuous Testing
Parasoft
 
Testware Hierarchy for Test Automation
Testware Hierarchy for Test AutomationTestware Hierarchy for Test Automation
Testware Hierarchy for Test Automation
Gregory Solovey
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choice
toddbr
 
Software Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails ApplicationsSoftware Quality and Test Strategies for Ruby and Rails Applications
Software Quality and Test Strategies for Ruby and Rails Applications
Bhavin Javia
 
Automation testing
Automation testingAutomation testing
Automation testing
Tomy Rhymond
 
Python - code quality and production monitoring
Python - code quality and production monitoringPython - code quality and production monitoring
Python - code quality and production monitoring
David Melamed
 
Hands-on Experience Model based testing with spec explorer
Hands-on Experience Model based testing with spec explorer Hands-on Experience Model based testing with spec explorer
Hands-on Experience Model based testing with spec explorer
Rachid Kherrazi
 
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
Alessandro Alpi
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
Alex Borsuk
 
XML2Selenium Technical Presentation
XML2Selenium Technical PresentationXML2Selenium Technical Presentation
XML2Selenium Technical Presentation
jazzteam
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applications
Chandra Sekhar Saripaka
 
SQL Server Integration Services and Analysis Services
SQL Server Integration Services and Analysis ServicesSQL Server Integration Services and Analysis Services
SQL Server Integration Services and Analysis Services
Mohan Arumugam
 
Rachid kherrazi-testing-asd-interface-compliance-with-asd spec
Rachid kherrazi-testing-asd-interface-compliance-with-asd specRachid kherrazi-testing-asd-interface-compliance-with-asd spec
Rachid kherrazi-testing-asd-interface-compliance-with-asd spec
Rachid Kherrazi
 
Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test
Gregory Solovey
 
Parallel run selenium tests in a good way
Parallel run selenium tests in a good  wayParallel run selenium tests in a good  way
Parallel run selenium tests in a good way
COMAQA.BY
 
Best practice adoption (and lack there of)
Best practice adoption (and lack there of)Best practice adoption (and lack there of)
Best practice adoption (and lack there of)
John Pape
 
Software Testing: Application And Script Independent Automation Framework: Th...
Software Testing: Application And Script Independent Automation Framework: Th...Software Testing: Application And Script Independent Automation Framework: Th...
Software Testing: Application And Script Independent Automation Framework: Th...
guest0efb5e
 
Automated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsAutomated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra Solutions
Quontra Solutions
 
No Devops Without Continuous Testing
No Devops Without Continuous TestingNo Devops Without Continuous Testing
No Devops Without Continuous Testing
Parasoft
 
Testware Hierarchy for Test Automation
Testware Hierarchy for Test AutomationTestware Hierarchy for Test Automation
Testware Hierarchy for Test Automation
Gregory Solovey
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choice
toddbr
 
Ad

Recently uploaded (20)

Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Agentic AI Use Cases using GenAI LLM models
Agentic AI Use Cases using GenAI LLM modelsAgentic AI Use Cases using GenAI LLM models
Agentic AI Use Cases using GenAI LLM models
Manish Chopra
 
Mastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core PillarsMastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core Pillars
Marcel David
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Shift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software DevelopmentShift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software Development
SathyaShankar6
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest VersionAdobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
usmanhidray
 
Sales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptxSales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptx
EliandoLawnote
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Agentic AI Use Cases using GenAI LLM models
Agentic AI Use Cases using GenAI LLM modelsAgentic AI Use Cases using GenAI LLM models
Agentic AI Use Cases using GenAI LLM models
Manish Chopra
 
Mastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core PillarsMastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core Pillars
Marcel David
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Shift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software DevelopmentShift Left using Lean for Agile Software Development
Shift Left using Lean for Agile Software Development
SathyaShankar6
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest VersionAdobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
usmanhidray
 
Sales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptxSales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptx
EliandoLawnote
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025Adobe Lightroom Classic Crack FREE Latest link 2025
Adobe Lightroom Classic Crack FREE Latest link 2025
kashifyounis067
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 

SF1 - Apex Development Best Practises

  • 1. Apex Development Best Practices http://bit.ly/sf1-dev-bp Sebastian Wagner, @tquiladotcom, Technical Architect @seb__wagner
  • 2. “I cannot teach anybody anything, I can only make them think” Socrates
  • 3. Agenda  Principles  Process  Development – Conventions – Queries – Loops – Tests  QA
  • 4. Process  track requirements  separate development sandboxes  use source control (git, Mercury, SVN)  automate deployment with CI  iterate
  • 5. Requirements  Understand – What is expected? – Why, what are the drivers?  Think – How to implement? – Impact, Dependencies  Challenge – Can it be flexed, to match platform features?
  • 6. Platform Advantages  Config over Code – workflows instead of triggers – Page Layout vs. Visualforce  Native over Custom – standard instead of custom objects – re-label field  Install/Deploy over Build – AppExchange – Github
  • 7. XP Principles  MVP - Minimum Viable Product (80/20 rule) – focus on the core features  KISS - Keep It Simple & Stupid – the simplest solution to meet the requirement – easy to use, read and change. looks simple  DRY – Don’t Repeat Yourself – Components, Labels, Templates, Abstraction, Service Classes  YAGNI – You Arent Gonna Need It – implement only WHEN you actually need it
  • 8. DEV – Structure The structure of code and config is clear and understandable  be consistent  use a naming convention  self describing names  declare constants and literal values in variable or config
  • 9. DEV – Comments Loops and more complex parts of the algorithms are clear and commented  clear code (what) over comments (why)  provide context and help understanding  describe purpose of classes and methods  do NOT comment trivial code
  • 10. DEV – Error Handling Exceptions and errors are managed using exception handling  catch in user facing code (e.g. in trigger or controller)  provide useful description if necessary  descriptive error messages  do NOT catch exceptions in service methods, unless you return your own error object
  • 11. DEV – Error Handling  insert Account Deactivation Handler  https://gist.github.com/sebwagner/5e556d492fa2cc010d c9
  • 12. Query - Conditions All SOQL queries are appropriately restricted by a WHERE clause or a LIMIT parameter  filter records by SOQL rather than code  use of indexes (Id, Text, Number) whenever possible  follows best practices for Query Optimizer (e.g. avoid to filter on NULL)
  • 14. Query – Efficiency Efficient use of queries for good performance  cache records for re-use in context  avoid querying the same object multiple times  exclude fields that are not needed  lazy load Blob and Large Text fields
  • 16. Loops - Limits Beware of the Governor Limits  loops (for, do-while) do NOT invoke – SOSL/SOQL statements – DML statements  method calls which use limits are not invoked in loops where avoidable e.g. Describes, Callouts, sendEmail()
  • 18. Testing – Code Coverage Code coverage is no lower than 90%. yet it is not everything, but  high coverage => less bugs => less frustration  keep testability in mind when writing code, because  if you can’t test it, it's an indicator for Code Smell
  • 19. Testing – Code Coverage ‘Alternative’
  • 20. Testing – Test Data Tests setup their own test data @isTest(seeAllData=false)  do NOT rely on organization data  if org data is need, limit to methods  use test data classes or methods for re-use
  • 23. Testing - Assertions Assertions are used to validate expected results  true testing, validation rather than only execution  +1 assert per test method  use the message parameter to provide context system.assert(Object,Object,message);
  • 25. Testing - Scenarios Tests validate positive and negative outcomes  Positive: execution with valid data / params  Negative: execution with invalid data / params  use system.runAs() to test – Dynamic Apex – Methods using with sharing or without sharing – Shared records
  • 27. Testing – Bulk Tests Code should be bulkified, so should be the tests  ensures you don’t hit governor limits  can uncover performance bottlenecks

Editor's Notes