Dreamforce 2014 Notes: Writing Apex and Visualforce Using Re-usable Patterns

Sharing is Caring

Why use patterns:

  • patterns help us be more efficient
  • patterns describe reusable solutions to common problems

Bulk Processing

  • Caching
  • create triggers w/ ability to process hundreds of lookups
  • challenge: queries, DML, memory
  • collect all keys from trigger object in Set Object
  • Query once using SOQL in clause with key set
  • cache results in map object
  • look up related values using map key

Apex Summary Rollup

  • Need to roll up from a child to a parent in a lookup relationship
  • No declarative option for rolling up in a lookup relationship
  • Identify parent IDs affected by change in child.
  • perform an aggregate query on child records
  • update parents using IDs

Configuration Abstraction

  • Manage values that change from environment to environment
  • Maintainability
  • Ease of use

Pagination

  • display records one page at a time
  • performance and maintainability
  • StandardSetController

Search And Sort

  • Allows users to apply search criteria and column sort
  • challenges: Performance and maintainability
  • reusuable Apex and component framework for Search and Sort
  • Dynamic SOQL to modify Where and Order by query clauses

http://developer.force.com/cookbook/recipe/trigger-pattern-for-tidy-streamlined-bulkified-triggers

Author: Brian Cline

Brian is a programmer living in Niagara Falls with ten years of development experience. He is passionate about automation, business process re-engineering, and gamification. For the last six years or so, he has been working with Salesforce and JavaScript.

Related Posts

Sharing is Caring