Skip to content

Instantly share code, notes, and snippets.

View RokhaO's full-sized avatar

Rokha Ou RokhaO

View GitHub Profile
@abd3
abd3 / Comprehensive Trigger Template
Created July 28, 2019 19:41
"Comprehensive Trigger Template" by Mike Leach
This text and the code below, originally came from a blog post from Mike Leach. That blog has subsequently been taken offline, but the contents are shared here for reference.
From Mike Leach:
====
I decided to create a more fluent Trigger template to address the following challenges and prevent me from repeatedly making the same mistakes:
* Bulkification best practices not provisioned by the Trigger creation wizard
* Use of the 7 boolean context variables in code (isInsert, isBefore, etc...) greatly impairs readability and long-term maintainability
* Trigger.old and Trigger.new collections are not available in certain contexts
* Asynchronous trigger support not natively built-in
@rsoesemann
rsoesemann / HttpMock.cls
Last active June 1, 2021 13:20
apex-http-mock
@IsTest
public class HttpMock implements HttpCalloutMock {
private static final String ANY_URL = null;
private Map<String, Map<String, Object>> responses = new Map<String, Map<String, Object>>();
// PUBLIC
@aidan-harding
aidan-harding / MultiMap.cls
Created August 30, 2024 15:22
A MultiMap for Salesforce Apex
/**
* @author [email protected]
* @date 29/08/2024
* @description A map where the items are lists of items and you can provide a function for how values map to keys.
* Oh, if we had generics....
*/
public class MultiMap {
private Map<Object, List<Object>> theMap;
private Type listType;