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