13
Apex 10 Commandments TerraSky Power Night 2013/12/05

4 TSPN_Apex 10 Commandments

Embed Size (px)

DESCRIPTION

2013/12/05 開催のTerraSky Power Night のLT資料です。

Citation preview

Page 1: 4 TSPN_Apex 10 Commandments

Apex 10 Commandments

TerraSky Power Night 2013/12/05

Page 2: 4 TSPN_Apex 10 Commandments

1

最初に自己紹介

やまむろ あつし

Page 3: 4 TSPN_Apex 10 Commandments

2

Apex 10 Commandments

Page 4: 4 TSPN_Apex 10 Commandments

3

#1 Thou shalt not put queries in for loops

Page 5: 4 TSPN_Apex 10 Commandments

4

#2 Thou shalt not put DML in for loops

Page 6: 4 TSPN_Apex 10 Commandments

5

#3 Thou shalt have a happy balance

between clicks & code

Page 7: 4 TSPN_Apex 10 Commandments

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

Page 8: 4 TSPN_Apex 10 Commandments

7

#6 Thou shalt utilize maps for queries

wherever possible

Page 9: 4 TSPN_Apex 10 Commandments

8

#7 Thou shalt make use of relationships to

reduce queries wherever possible

Page 10: 4 TSPN_Apex 10 Commandments

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.

Page 11: 4 TSPN_Apex 10 Commandments

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”)

Page 12: 4 TSPN_Apex 10 Commandments

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.

Page 13: 4 TSPN_Apex 10 Commandments

12

#11 Research the session content beforehand

If you go to Dreamforce・・・