Code reviews – pointed questions for Apex code review

Let's get started with the following set of questions:

  • Does this unit of code have more than four if statements?

    Methods with more than four if statements (if(), else if(), else()) pose a number of related problems. First, due to the verbosity of Apex, numerous if statements will necessarily mean longer methods. Second, because each statement creates another logical path through the method, each also represents at least one additional test case to be written. The fewer the number of logical paths through your code, the simpler it is to understand, test, and refactor. Unfortunately, sometimes the business logic we are calculating requires a number of conditionals. For instance, calculating tax ...

Get Mastering Application Development with Force.com now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.