<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Ruby on BoochTek, LLC</title><link>https://blog.boochtek.com/categories/ruby/</link><description>Recent content in Ruby on BoochTek, LLC</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 22 Jun 2015 23:55:17 +0000</lastBuildDate><atom:link href="https://blog.boochtek.com/categories/ruby/index.xml" rel="self" type="application/rss+xml"/><item><title>Not Quite Callbacks</title><link>https://blog.boochtek.com/posts/not-quite-callbacks/</link><pubDate>Mon, 22 Jun 2015 23:55:17 +0000</pubDate><guid>https://blog.boochtek.com/posts/not-quite-callbacks/</guid><description>&lt;p&gt;I&amp;rsquo;ve been working on application architectures based on &lt;a href="http://confreaks.tv/videos/rubymidwest2011-keynote-architecture-the-lost-years"&gt;Uncle Bob&amp;rsquo;s Ruby Midwest talk&lt;/a&gt;, following the &lt;a href="http://alistair.cockburn.us/Hexagonal+architecture"&gt;hexagonal architectural pattern&lt;/a&gt;. I posted &lt;a href="https://blog.boochtek.com/posts/2015/02/23/hexagonal-rails-controllers"&gt;an article a couple months ago showing a way that works fairly well in Rails&lt;/a&gt;, and some &lt;a href="https://github.com/boochtek/hexagonal-rails"&gt;accompanying Rails example code&lt;/a&gt;. But there was one thing I wasn&amp;rsquo;t quite happy with.&lt;/p&gt;
&lt;p&gt;The problem is that we used callbacks (actually, a publish/subscribe mechanism) in a situation where they don&amp;rsquo;t seem to quite fit:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; def show
interactor.on(:display) { |order| render order }
interactor.on(:not_found) { |order_id| render status: 404 }
interactor.get(params[:id])
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What we really want is to respond in different ways, depending on the result of the call to &lt;code&gt;interactor.get()&lt;/code&gt;. There&amp;rsquo;s no good reason to define the responses before the call. It makes a lot more sense to define the responses after the call, because they&amp;rsquo;ll &lt;strong&gt;happen&lt;/strong&gt; after the call. I&amp;rsquo;d much prefer that the code be written in the order that it will be run.&lt;/p&gt;</description></item><item><title>Architectural Thoughts</title><link>https://blog.boochtek.com/posts/architectural-thoughts/</link><pubDate>Mon, 01 Jun 2015 23:51:59 +0000</pubDate><guid>https://blog.boochtek.com/posts/architectural-thoughts/</guid><description>&lt;p&gt;I&amp;rsquo;ve started working on my own framework in Ruby in the past couple days. It&amp;rsquo;s built upon my recent work at understanding &lt;a href="http://confreaks.tv/videos/rubymidwest2011-keynote-architecture-the-lost-years"&gt;Uncle Bob&amp;rsquo;s Ruby Midwest 2011 talk&lt;/a&gt;, and his article on &lt;a href="http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html"&gt;Clean Architecture&lt;/a&gt;, and the resulting hexagonal architecture (AKA ports and adapters).&lt;/p&gt;
&lt;p&gt;Somehow my research in that vein led me to &lt;a href="https://www.destroyallsoftware.com/talks/boundaries"&gt;Gary Bernhardt&amp;rsquo;s Boundaries talk&lt;/a&gt;. I&amp;rsquo;ve read a lot about the talk, and knew about the idea of &amp;ldquo;functional core / imperative shell&amp;rdquo;. And I&amp;rsquo;ve worked with a lot of similar ideas lately. But I believe this is the first time that I actually watched the whole video.&lt;/p&gt;</description></item><item><title>Hexagonal Rails Controllers</title><link>https://blog.boochtek.com/posts/hexagonal-rails-controllers/</link><pubDate>Mon, 23 Feb 2015 23:50:28 +0000</pubDate><guid>https://blog.boochtek.com/posts/hexagonal-rails-controllers/</guid><description>&lt;p&gt;I&amp;rsquo;ve had a long love-hate relationship with Rails. I love the MVC framework and how it&amp;rsquo;s improved our speed of writing web apps. But I&amp;rsquo;ve never really been completely happy with it. I don&amp;rsquo;t generally agree with most of its opinions. I prefer models that follow the Data Mapper pattern, not the Active Record pattern. This includes separating the persistence layer from the models&amp;rsquo; business logic. I prefer Slim or HAML to ERB. I prefer RSpec to Test::Unit or MiniTest. When Merb hit the scene, I was ready to make the jump, until Merb merged with Rails.&lt;/p&gt;</description></item><item><title>Ruby Pattern: Parameterized Module Inclusion</title><link>https://blog.boochtek.com/posts/ruby-parameterized-module-inclusion/</link><pubDate>Mon, 14 Apr 2014 23:57:29 +0000</pubDate><guid>https://blog.boochtek.com/posts/ruby-parameterized-module-inclusion/</guid><description>&lt;p&gt;I&amp;rsquo;ve run across a pattern in Ruby lately that I really like. It solves some problems that I&amp;rsquo;ve struggled with for several years. Let me start with the problems.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s say you want to include an ORM in a model class, and want to tell it what database table to use. Typically, you&amp;rsquo;d do this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class User
include MyORM::Model
table 'people'
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But that &lt;code&gt;table&lt;/code&gt; call is more like an option to the module inclusion than anything else. So what we&amp;rsquo;d really like is something like this:&lt;/p&gt;</description></item><item><title>Includable ActiveRecord</title><link>https://blog.boochtek.com/posts/includable-activerecord/</link><pubDate>Mon, 10 Feb 2014 12:09:53 +0000</pubDate><guid>https://blog.boochtek.com/posts/includable-activerecord/</guid><description>&lt;p&gt;I created a Ruby gem recently, called &lt;a href="https://github.com/boochtek/includable-activerecord"&gt;includable-activerecord&lt;/a&gt;. It&amp;rsquo;s pretty small, but I thought I might explain why I created it, and discuss its implementation.&lt;/p&gt;
&lt;h1 id="classical-inheritance"&gt;Classical Inheritance&lt;/h1&gt;
&lt;p&gt;When you use ActiveRecord, you normally include it in your model like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class User &amp;lt; ActiveRecord::Base
# ...
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your &lt;code&gt;User&lt;/code&gt; class is inheriting from the &lt;code&gt;ActiveRecord::Base&lt;/code&gt; class. This is class-based inheritance, also called &amp;ldquo;classical&amp;rdquo; inheritance. (That&amp;rsquo;s &amp;ldquo;classical&amp;rdquo; as in &amp;ldquo;class&amp;rdquo;, not as a synonym for &amp;ldquo;traditional&amp;rdquo;.) Class-based inheritance represents an &amp;ldquo;is-a&amp;rdquo; relationship. So we&amp;rsquo;re saying that a user is an ActiveRecord base. Another way to say this is that &lt;code&gt;User&lt;/code&gt; is a subclass of &lt;code&gt;ActiveRecord::Base.&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
There are a few problems with this. First, what is a &amp;ldquo;base&amp;rdquo;? The name was chosen because it&amp;rsquo;s a base class. But just like we don&amp;rsquo;t give factory classes names like &lt;code&gt;UserFactory&lt;/code&gt; (at least not in Ruby), we shouldn&amp;rsquo;t name base classes &lt;code&gt;Base&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>My Thoughts on Python vs. Ruby</title><link>https://blog.boochtek.com/posts/my-thoughts-on-python-vs-ruby/</link><pubDate>Fri, 22 Feb 2013 11:03:06 +0000</pubDate><guid>https://blog.boochtek.com/posts/my-thoughts-on-python-vs-ruby/</guid><description>&lt;p&gt;I&amp;rsquo;ve been using Python at work for the past few months.  I learned Python back in the early 2000s, but never used it for any large projects.  I learned Ruby in late 2005, and it quickly became my language of choice for most cases.&lt;/p&gt;
&lt;p&gt;So while I still prefer Ruby, and will likely use Ruby more in the future than Python, I wanted to assess the strengths and weaknesses of Python in relation to Ruby.  Perhaps some of the lessons could be applied when writing Ruby, and it could help to decide when to use each.  Also, I&amp;rsquo;m interested in programming language design, and wanted to document pros and cons in that light.&lt;/p&gt;</description></item><item><title>Debugging Pattern – Grenade</title><link>https://blog.boochtek.com/posts/grenade-debugging-pattern/</link><pubDate>Wed, 11 Jan 2012 18:59:59 +0000</pubDate><guid>https://blog.boochtek.com/posts/grenade-debugging-pattern/</guid><description>&lt;p&gt;I&amp;rsquo;ve been more interested in programming patterns lately, partly due to the&lt;br&gt;
Ruby community&amp;rsquo;s recent interest &amp;mdash; especially the Ruby Rogue podcast&amp;rsquo;s&lt;br&gt;
love affair with &amp;ldquo;Smalltalk Best Practice Patterns&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;I consider most of the patterns in &amp;ldquo;Smalltalk Best Practice Patterns&amp;rdquo; to be&lt;br&gt;
patterns &amp;ldquo;in the small&amp;rdquo; &amp;mdash; things that are typically employed on a single line&lt;br&gt;
or method. The Gang Of Four patterns are more medium sized, dealing with methods&lt;br&gt;
and classes. The PEAA book covers architectural-scale patterns. I suppose&lt;br&gt;
&amp;ldquo;The Pragmatic Programmer&amp;rdquo; and similar books could (should!) be considered&lt;br&gt;
to be very general patterns, mostly about the practice of programming.&lt;/p&gt;</description></item></channel></rss>