<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Pulling Code Out of Triggers</title>
	<atom:link href="http://www.x2od.com/2009/05/18/pulling-code-out-of-triggers.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.x2od.com/2009/05/18/pulling-code-out-of-triggers.html</link>
	<description>Salesforce Configuration, Administration, and Development</description>
	<lastBuildDate>Tue, 15 Jun 2010 19:00:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Auto-convert Contact-matching Leads : X-Squared On-Demand</title>
		<link>http://www.x2od.com/2009/05/18/pulling-code-out-of-triggers.html/comment-page-1#comment-11026</link>
		<dc:creator>Auto-convert Contact-matching Leads : X-Squared On-Demand</dc:creator>
		<pubDate>Thu, 11 Feb 2010 18:23:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.x2od.com/?p=583#comment-11026</guid>
		<description>[...] the trigger. Note that I followed my own advice from Pulling Code Out of Triggers. (Other trigger classes have been [...]</description>
		<content:encoded><![CDATA[<p>[...] the trigger. Note that I followed my own advice from Pulling Code Out of Triggers. (Other trigger classes have been [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Douglas</title>
		<link>http://www.x2od.com/2009/05/18/pulling-code-out-of-triggers.html/comment-page-1#comment-2678</link>
		<dc:creator>Jeff Douglas</dc:creator>
		<pubDate>Fri, 22 May 2009 21:21:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.x2od.com/?p=583#comment-2678</guid>
		<description>David, thanks for taking my crappy code and making it better. I won&#039;t receive a bill will I? I find your reasoning sound and have been refactoring a number of triggers in this same way.</description>
		<content:encoded><![CDATA[<p>David, thanks for taking my crappy code and making it better. I won&#8217;t receive a bill will I? I find your reasoning sound and have been refactoring a number of triggers in this same way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Manelski</title>
		<link>http://www.x2od.com/2009/05/18/pulling-code-out-of-triggers.html/comment-page-1#comment-2510</link>
		<dc:creator>Dave Manelski</dc:creator>
		<pubDate>Tue, 19 May 2009 01:40:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.x2od.com/?p=583#comment-2510</guid>
		<description>We have a few classes with methods used by multiple triggers.  In lieu of passing the trigger set (sObjects), we&#039;ve opted for passing primivitive data types only between triggers and classes, purposefully to reduce dependencies.  In your example, I would probably opt for passing a list of strings (for the Ids in the trigger set) and perform a SOQL in the class.

By keeping these dependencies to a minimum, you can easier package code, among other benefits. I&#039;ve adopted this &quot;best practice&quot; based on observation and advice of more talented coders than myself so I&#039;d be curious to find out how someone with formal computer science training weighs in on this.</description>
		<content:encoded><![CDATA[<p>We have a few classes with methods used by multiple triggers.  In lieu of passing the trigger set (sObjects), we&#8217;ve opted for passing primivitive data types only between triggers and classes, purposefully to reduce dependencies.  In your example, I would probably opt for passing a list of strings (for the Ids in the trigger set) and perform a SOQL in the class.</p>
<p>By keeping these dependencies to a minimum, you can easier package code, among other benefits. I&#8217;ve adopted this &#8220;best practice&#8221; based on observation and advice of more talented coders than myself so I&#8217;d be curious to find out how someone with formal computer science training weighs in on this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Schach</title>
		<link>http://www.x2od.com/2009/05/18/pulling-code-out-of-triggers.html/comment-page-1#comment-2494</link>
		<dc:creator>David Schach</dc:creator>
		<pubDate>Mon, 18 May 2009 20:37:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.x2od.com/?p=583#comment-2494</guid>
		<description>I was just thinking about something similar today - with some logic and passing a String parameter, one could use the same class to update a single field to multiple values.  For instance, an opportunity trigger to Account.Type -&gt; Customer if total won opp value is &gt;0, and -&gt; VIP Customer if total won opp value &gt; 250,000.
The possibilities are limitless!</description>
		<content:encoded><![CDATA[<p>I was just thinking about something similar today &#8211; with some logic and passing a String parameter, one could use the same class to update a single field to multiple values.  For instance, an opportunity trigger to Account.Type -&gt; Customer if total won opp value is &gt;0, and -&gt; VIP Customer if total won opp value &gt; 250,000.<br />
The possibilities are limitless!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Hemmeter</title>
		<link>http://www.x2od.com/2009/05/18/pulling-code-out-of-triggers.html/comment-page-1#comment-2491</link>
		<dc:creator>Scott Hemmeter</dc:creator>
		<pubDate>Mon, 18 May 2009 20:11:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.x2od.com/?p=583#comment-2491</guid>
		<description>I use this approach with a slight mod.

I have 1 trigger for each object and it fires for all events where I have code.  Example of my Leads trigger below. It&#039;s basically what you are suggesting, but it&#039;s one common trigger and I add if/thens based upon the event that is firing.

This way there is 1 trigger and 1 class for each object.

trigger Leads on Lead (after insert, after update) {
	
// AFTER INSERT
if(Trigger.isAfter &amp;&amp; Trigger.isInsert){
	Leads l = new Leads();
        l.CreateCampaignMembers(Trigger.new);
}
    
// AFTER UPDATE
if(Trigger.isAfter &amp;&amp; Trigger.isUpdate){
	Leads l = new Leads();
        l.setOpportunityDefaults(Trigger.new, Trigger.oldMap);
        l.transferOpptyFromLeadToAccount(Trigger.new, Trigger.oldMap);
}

}</description>
		<content:encoded><![CDATA[<p>I use this approach with a slight mod.</p>
<p>I have 1 trigger for each object and it fires for all events where I have code.  Example of my Leads trigger below. It&#8217;s basically what you are suggesting, but it&#8217;s one common trigger and I add if/thens based upon the event that is firing.</p>
<p>This way there is 1 trigger and 1 class for each object.</p>
<p>trigger Leads on Lead (after insert, after update) {</p>
<p>// AFTER INSERT<br />
if(Trigger.isAfter &amp;&amp; Trigger.isInsert){<br />
	Leads l = new Leads();<br />
        l.CreateCampaignMembers(Trigger.new);<br />
}</p>
<p>// AFTER UPDATE<br />
if(Trigger.isAfter &amp;&amp; Trigger.isUpdate){<br />
	Leads l = new Leads();<br />
        l.setOpportunityDefaults(Trigger.new, Trigger.oldMap);<br />
        l.transferOpptyFromLeadToAccount(Trigger.new, Trigger.oldMap);<br />
}</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy Ross</title>
		<link>http://www.x2od.com/2009/05/18/pulling-code-out-of-triggers.html/comment-page-1#comment-2487</link>
		<dc:creator>Jeremy Ross</dc:creator>
		<pubDate>Mon, 18 May 2009 17:11:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.x2od.com/?p=583#comment-2487</guid>
		<description>I prefer to keep triggers very lean and free of business logic.  I&#039;d probably disagree with commenting your class with which triggers call it, for a few reasons.  1) The class shouldn&#039;t know or care who calls it - the beauty of reuse, 2) someone will inevitably create a new client of the class and not update the &quot;users&quot; comment in the class, 3) this is related to 2, which is you&#039;ll have a false sense of security of who is using the class.  

The &quot;show dependencies&quot; button on the apex class screen would be infinitely more useful if it would show dependents instead of dependencies.</description>
		<content:encoded><![CDATA[<p>I prefer to keep triggers very lean and free of business logic.  I&#8217;d probably disagree with commenting your class with which triggers call it, for a few reasons.  1) The class shouldn&#8217;t know or care who calls it &#8211; the beauty of reuse, 2) someone will inevitably create a new client of the class and not update the &#8220;users&#8221; comment in the class, 3) this is related to 2, which is you&#8217;ll have a false sense of security of who is using the class.  </p>
<p>The &#8220;show dependencies&#8221; button on the apex class screen would be infinitely more useful if it would show dependents instead of dependencies.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
