Upload
terrasky
View
751
Download
0
Embed Size (px)
DESCRIPTION
2013/12/05 開催のTerraSky Power Night のLT資料です。
Citation preview
Apex 10 Commandments
TerraSky Power Night 2013/12/05
1
最初に自己紹介
やまむろ あつし
2
Apex 10 Commandments
3
#1 Thou shalt not put queries in for loops
4
#2 Thou shalt not put DML in for loops
5
#3 Thou shalt have a happy balance
between clicks & code
6
#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
7
#6 Thou shalt utilize maps for queries
wherever possible
8
#7 Thou shalt make use of relationships to
reduce queries wherever possible
9
#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.
10
#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”)
11
#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.
12
#11 Research the session content beforehand
If you go to Dreamforce・・・