<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Binary Logic &#187; resources</title>
	<atom:link href="http://www.binarylogic.com/tag/resources/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.binarylogic.com</link>
	<description>Ben Johnson's thoughts and programming techniques</description>
	<lastBuildDate>Sat, 23 Jan 2010 21:19:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Discontinuing Resourcelogic</title>
		<link>http://www.binarylogic.com/2009/10/06/discontinuing-resourcelogic/</link>
		<comments>http://www.binarylogic.com/2009/10/06/discontinuing-resourcelogic/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 04:31:47 +0000</pubDate>
		<dc:creator>benjohnson</dc:creator>
				<category><![CDATA[Resourcelogic]]></category>
		<category><![CDATA[discontinuing]]></category>
		<category><![CDATA[resources]]></category>

		<guid isPermaLink="false">http://www.binarylogic.com/?p=805</guid>
		<description><![CDATA[Lately I&#8217;ve been really going back and forth between using tools like resourcelogic, inherited_resources, resource_controller, etc. And I gave each one of these libraries a more than fair shot. I&#8217;ve used all of them extensively, that&#8217;s the whole reason I created resourcelogic to begin with. I really liked resource_controller, so much that I decided to [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been really going back and forth between using tools like <a href="http://github.com/binarylogic/resourcelogic">resourcelogic</a>, <a href="http://github.com/josevalim/inherited_resources">inherited_resources</a>, <a href="http://github.com/giraffesoft/resource_controller">resource_controller</a>, etc. And I gave each one of these libraries a more than fair shot. I&#8217;ve used all of them extensively, that&#8217;s the whole reason I created resourcelogic to begin with. I really liked resource_controller, so much that I decided to take it and kind of make my own version called resourcelogic. I ended up changing it quite a bit, and it worked out well, but it got out of hand. So I&#8217;m going to address why I advise against using libraries like this:<br />
<span id="more-805"></span></p>
<h2>Deviating from standards makes it harder to work with other programmers</h2>
<p>You have to think that certain things in rails are there for a reason. Rails is a result of thousands of programmer&#8217;s ideas, its used by extensively by programming teams large and small, and has tremendous success. There is a reason for that. Chances are, you aren&#8217;t going to sit around one day and come up with this idea that takes rails to the next level. I&#8217;m not trying to be a Debbie Downer and tell people not to try and improve rails or be innovative. That&#8217;s not the message I&#8217;m trying to send here. What I&#8217;m trying to say is that if you are sitting around and you come up with this crazy idea that deviates quite a bit from the rails standards, it&#8217;s probably wrong, even if you think it&#8217;s cool. I thought I did that with resourcelogic. I thought I was Mr. Awesome and I came up with this new development style for rails that was better than anything done before. I know that sounds pretty conceited but I was on my high horse. I thought the development style behind resourcelogic was awesome and I was going to share it with the rails community and people were going to eat it up.</p>
<p>So I ran with it, I developed an entire project with it by myself. Probably the most important project I&#8217;ve ever developed. I gave all of these libraries a more than fair shot. In the end, it made my project more confusing. The red flag was showing my code to another programmer. I had to explain what was going on and he was still kind of confused. Once he got it, he didn&#8217;t like it. This is not good. I didn&#8217;t like the thought of having to go through this with every programmer I was going to hire for this project. Which leads me to my next point:</p>
<h2>You lose intent</h2>
<p>This is probably my biggest complaint: you lose intent. There is a lot of code hidden away, so when you see small controllers with 4 &#8211; 5 lines of code providing all of this application specific functionality it kind of makes you wonder what is going on. There is no direct intent saying &#8220;this is what I&#8217;m doing&#8221;. There&#8217;s a lot of magic. My controllers looked like this:</p>
<pre class="ruby">
create.before { ... }
create.wants.xml { ... }
create.wants.js { ... }
create.after { ... }
index.before { ... }

def my_own_custom_action
...
end
</pre>
<p>It just felt wrong. There is something refreshing about seeing this:</p>
<pre class="ruby">
def create
  @user = User.new(params[:user])
  respond_to do |wants|
    if @user.save
      wants.html { redirect_to users_url }
      wants.js { render :inline => "window.location = '<%= users_url %>';" }
   else
     wants.html { render :action => :new }
     wants.js { ... }
   end
  end
end
</pre>
<p>Is that more code? Yes. Who said more code is bad when it makes more sense? I can look at the create method and know EXACTLY what is going on. I can add in some weird edge case if I need. I can do whatever the hell I want and I&#8217;m not confined to the standards set in resourcelogic. I don&#8217;t feel like I&#8217;m deviating from a pattern by doing that either. Sure, with resourcelogic you can write your own create method, but then I feel dirty, like I&#8217;m not following the pattern my application has defined.</p>
<h2>Upgrading rails</h2>
<p>What example would you feel more comfortable with if you were upgrading from rails 2 to 3? The one that uses a pattern that deviates from the rails standards, or one that uses the most basic of rails code? I would feel better with the second. That is standard rails code that I know for a 100% fact is going to be supported in Rails 3. Sure, you could up date the library in the first example to work with rails 3, but in my opinion thats a sign the library is messing with code it shouldn&#8217;t.</p>
<h2>Conclusion</h2>
<p>I&#8217;m not trying to knock libraries like resource_controller or inherited_resources, hell I wrote my own version called resourcelogic. So I would be knocking myself if I did. I just don&#8217;t think they are needed. Rails is simple to begin with. There is nothing wrong with writing out a full controller method. It&#8217;s simple, its direct, its clear, and it follows the rails standards. I can pick any programmer from the rails community and not have to say a word and they would understand a standard rails action. While at the same time I could show them a &#8220;resource controller&#8221; and a lot of people would wonder what the hell is going on. More importantly, edge cases feel clean. If a controller needs to do something a little bit different, that&#8217;s fine. I have full control of what is going on. I don&#8217;t have to use some weird API with before and after hooks to add in edge cases.</p>
<p>So the bottom line is that I am stopping support for resourcelogic. I will more than likely remove it from github because I don&#8217;t want to send people down the wrong path thinking its a good tool to use. For a simple project its probably fine, but in the end it&#8217;s just not worth it. All of the time and effort I spent writing resourcelogic and implementing it into my app was kind of a waste. With that time I could have made some major advancements and improvements to my application. But it&#8217;s things like this that make you a better programmer, you live and you learn. The lesson I learned is to not deviate from the rails standards too much. Use what they give you, chances are it will work out just fine because there are thousands of other programmers using the same tools to build a large variety of projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.binarylogic.com/2009/10/06/discontinuing-resourcelogic/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
	</channel>
</rss>
