SlideShare une entreprise Scribd logo
1  sur  13
Télécharger pour lire hors ligne
TerraSky Power Night 2013/12/05

Apex 10 Commandments
最初に自己紹介

やまむろ あつし

1
Apex 10 Commandments

2
#1 Thou shalt not put queries in for loops

3
#2 Thou shalt not put DML in for loops

4
#3 Thou shalt have a happy balance
between clicks & code

5
#4 Thou shalt only put one trigger per object

#5 Thou shalt not put code in triggers other than
calling methods and managing execution order

6
#6 Thou shalt utilize maps for queries
wherever possible

7
#7 Thou shalt make use of relationships to
reduce queries wherever possible

8
#8 Thou shalt aim for 100% test coverage

In general test your methods for:
 Positive effects.
• Given proper input it should act like this.

• Not just happy path, but all logic branches.

 Negative effects.
• Given bad data it should error like this.

 Role/Profile/User effects
• Given a user with X profile and Y role it should
act like this.
9
#9 Thou shalt write meaningful and useful tests

It’s not a test without assertions.
 Assert(A==B, “Reason for Assert failure”)

 AssertEquals(A,B, “Reason for Assert failure”)
 AssertNotEquals(A,B, “Reason for Assert
failure”)

10
#10 Thou shalt limit future calls and use
asynchronous code where possible
In general bias towards batch apex

 Ensure it runs as efficiently as possible.
 If you need @future methods.

11
#11 Research the session content beforehand
If you go to Dreamforce・・・

12

Contenu connexe

En vedette (6)

5 TSPN_Write Apex and Visualforce Using Re-usable Patterns
5 TSPN_Write Apex and Visualforce Using Re-usable Patterns5 TSPN_Write Apex and Visualforce Using Re-usable Patterns
5 TSPN_Write Apex and Visualforce Using Re-usable Patterns
 
5分で振り返る過去10回のdreamforce
5分で振り返る過去10回のdreamforce5分で振り返る過去10回のdreamforce
5分で振り返る過去10回のdreamforce
 
2 TSPN_Dreamforceに見たSalesforceが描く世界(大友)
2 TSPN_Dreamforceに見たSalesforceが描く世界(大友)2 TSPN_Dreamforceに見たSalesforceが描く世界(大友)
2 TSPN_Dreamforceに見たSalesforceが描く世界(大友)
 
01 awsとsalesforceを使ったエコシステム ファイル編
01 awsとsalesforceを使ったエコシステム ファイル編01 awsとsalesforceを使ったエコシステム ファイル編
01 awsとsalesforceを使ったエコシステム ファイル編
 
7 TSPN_次世代UIフレームワークについて
7 TSPN_次世代UIフレームワークについて7 TSPN_次世代UIフレームワークについて
7 TSPN_次世代UIフレームワークについて
 
02 singletonとflyweightを使った省エネapex
02 singletonとflyweightを使った省エネapex02 singletonとflyweightを使った省エネapex
02 singletonとflyweightを使った省エネapex
 

Similaire à 4 TSPN_Apex 10 Commandments

Similaire à 4 TSPN_Apex 10 Commandments (20)

The Apex Ten Commandments
The Apex Ten CommandmentsThe Apex Ten Commandments
The Apex Ten Commandments
 
Salesforce Apex Ten Commandments
Salesforce Apex Ten CommandmentsSalesforce Apex Ten Commandments
Salesforce Apex Ten Commandments
 
Apex 10 commandments df14
Apex 10 commandments df14Apex 10 commandments df14
Apex 10 commandments df14
 
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...
 
Helping Programmers Write Better Tests
Helping Programmers Write Better TestsHelping Programmers Write Better Tests
Helping Programmers Write Better Tests
 
Test-Driven Development
 Test-Driven Development  Test-Driven Development
Test-Driven Development
 
Effective Unit Testing
Effective Unit TestingEffective Unit Testing
Effective Unit Testing
 
Shift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David LaulusaShift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David Laulusa
 
Test Driven Development with Laravel
Test Driven Development with LaravelTest Driven Development with Laravel
Test Driven Development with Laravel
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Manual Testing.
Manual Testing.Manual Testing.
Manual Testing.
 
TDD: seriously, try it! 
TDD: seriously, try it! TDD: seriously, try it! 
TDD: seriously, try it! 
 
Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)
 
Strategic Testing (CodeMash 2016)
Strategic Testing (CodeMash 2016)Strategic Testing (CodeMash 2016)
Strategic Testing (CodeMash 2016)
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
Software Testing Introduction (Part 1)
Software Testing Introduction (Part 1)Software Testing Introduction (Part 1)
Software Testing Introduction (Part 1)
 
Your Tests Are Not Your Specs
Your Tests Are Not Your SpecsYour Tests Are Not Your Specs
Your Tests Are Not Your Specs
 
Getting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud ShaonGetting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud Shaon
 
Unit testing
Unit testingUnit testing
Unit testing
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven Development
 

Plus de TerraSky

12 power night2014 miyanishi
12 power night2014 miyanishi12 power night2014 miyanishi
12 power night2014 miyanishi
TerraSky
 
11 power nignt_furuta
11 power nignt_furuta11 power nignt_furuta
11 power nignt_furuta
TerraSky
 
10 power night2014_uematsu
10 power night2014_uematsu10 power night2014_uematsu
10 power night2014_uematsu
TerraSky
 
9 power night2014_iwai
9 power night2014_iwai9 power night2014_iwai
9 power night2014_iwai
TerraSky
 
8 power night2014_nakamura
8 power night2014_nakamura8 power night2014_nakamura
8 power night2014_nakamura
TerraSky
 
7 power night2014_kanbayashi
7 power night2014_kanbayashi7 power night2014_kanbayashi
7 power night2014_kanbayashi
TerraSky
 
6 power night2014_sasaki
6 power night2014_sasaki6 power night2014_sasaki
6 power night2014_sasaki
TerraSky
 
5 power night2014_totsuka
5 power night2014_totsuka5 power night2014_totsuka
5 power night2014_totsuka
TerraSky
 
4 power night2014_yoshikawa
4 power night2014_yoshikawa4 power night2014_yoshikawa
4 power night2014_yoshikawa
TerraSky
 
3 power nignt2014_yamamoto
3 power nignt2014_yamamoto3 power nignt2014_yamamoto
3 power nignt2014_yamamoto
TerraSky
 
2 power night2014_erp
2 power night2014_erp2 power night2014_erp
2 power night2014_erp
TerraSky
 
1 power night2014_imaoka
1 power night2014_imaoka1 power night2014_imaoka
1 power night2014_imaoka
TerraSky
 
13 power nignt2014_yanase
13 power nignt2014_yanase13 power nignt2014_yanase
13 power nignt2014_yanase
TerraSky
 

Plus de TerraSky (20)

TerraSky PowerNight - Salesforce is ready for ERP -
TerraSky PowerNight - Salesforce is ready for ERP -TerraSky PowerNight - Salesforce is ready for ERP -
TerraSky PowerNight - Salesforce is ready for ERP -
 
TerraSky PowerNight myEinstein
TerraSky PowerNight  myEinsteinTerraSky PowerNight  myEinstein
TerraSky PowerNight myEinstein
 
TerraSky PowerNight Soql performance explained
TerraSky PowerNight  Soql performance explainedTerraSky PowerNight  Soql performance explained
TerraSky PowerNight Soql performance explained
 
セールスフォース的開発メソッドのススメ 須山洋輔
セールスフォース的開発メソッドのススメ 須山洋輔セールスフォース的開発メソッドのススメ 須山洋輔
セールスフォース的開発メソッドのススメ 須山洋輔
 
Xivelyで楽々IoT 岩井哲郎
Xivelyで楽々IoT 岩井哲郎Xivelyで楽々IoT 岩井哲郎
Xivelyで楽々IoT 岩井哲郎
 
これだけは押さえておきたいDreamforceを楽しむための英語力 下川原章仁
これだけは押さえておきたいDreamforceを楽しむための英語力 下川原章仁これだけは押さえておきたいDreamforceを楽しむための英語力 下川原章仁
これだけは押さえておきたいDreamforceを楽しむための英語力 下川原章仁
 
Dreamforce2016から読み解く、これからのit 大友幹
Dreamforce2016から読み解く、これからのit 大友幹Dreamforce2016から読み解く、これからのit 大友幹
Dreamforce2016から読み解く、これからのit 大友幹
 
12 power night2014 miyanishi
12 power night2014 miyanishi12 power night2014 miyanishi
12 power night2014 miyanishi
 
11 power nignt_furuta
11 power nignt_furuta11 power nignt_furuta
11 power nignt_furuta
 
10 power night2014_uematsu
10 power night2014_uematsu10 power night2014_uematsu
10 power night2014_uematsu
 
9 power night2014_iwai
9 power night2014_iwai9 power night2014_iwai
9 power night2014_iwai
 
8 power night2014_nakamura
8 power night2014_nakamura8 power night2014_nakamura
8 power night2014_nakamura
 
7 power night2014_kanbayashi
7 power night2014_kanbayashi7 power night2014_kanbayashi
7 power night2014_kanbayashi
 
6 power night2014_sasaki
6 power night2014_sasaki6 power night2014_sasaki
6 power night2014_sasaki
 
5 power night2014_totsuka
5 power night2014_totsuka5 power night2014_totsuka
5 power night2014_totsuka
 
4 power night2014_yoshikawa
4 power night2014_yoshikawa4 power night2014_yoshikawa
4 power night2014_yoshikawa
 
3 power nignt2014_yamamoto
3 power nignt2014_yamamoto3 power nignt2014_yamamoto
3 power nignt2014_yamamoto
 
2 power night2014_erp
2 power night2014_erp2 power night2014_erp
2 power night2014_erp
 
1 power night2014_imaoka
1 power night2014_imaoka1 power night2014_imaoka
1 power night2014_imaoka
 
13 power nignt2014_yanase
13 power nignt2014_yanase13 power nignt2014_yanase
13 power nignt2014_yanase
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

4 TSPN_Apex 10 Commandments

  • 1. TerraSky Power Night 2013/12/05 Apex 10 Commandments
  • 4. #1 Thou shalt not put queries in for loops 3
  • 5. #2 Thou shalt not put DML in for loops 4
  • 6. #3 Thou shalt have a happy balance between clicks & code 5
  • 7. #4 Thou shalt only put one trigger per object #5 Thou shalt not put code in triggers other than calling methods and managing execution order 6
  • 8. #6 Thou shalt utilize maps for queries wherever possible 7
  • 9. #7 Thou shalt make use of relationships to reduce queries wherever possible 8
  • 10. #8 Thou shalt aim for 100% test coverage In general test your methods for:  Positive effects. • Given proper input it should act like this. • Not just happy path, but all logic branches.  Negative effects. • Given bad data it should error like this.  Role/Profile/User effects • Given a user with X profile and Y role it should act like this. 9
  • 11. #9 Thou shalt write meaningful and useful tests It’s not a test without assertions.  Assert(A==B, “Reason for Assert failure”)  AssertEquals(A,B, “Reason for Assert failure”)  AssertNotEquals(A,B, “Reason for Assert failure”) 10
  • 12. #10 Thou shalt limit future calls and use asynchronous code where possible In general bias towards batch apex  Ensure it runs as efficiently as possible.  If you need @future methods. 11
  • 13. #11 Research the session content beforehand If you go to Dreamforce・・・ 12