Your Website2022-11-23T13:08:27+00:00http://stem.psSimon Stemplingersimon@stem.pshttp://example.com/podcast/liefery/2019/04/14/podcast-interview-digitale-gruender-part-2Interview on Digitale Gründer Podcast (Part 2)2019-04-14T15:00:00+00:002019-04-14T15:00:00+00:00Simon Stemplingerhttp://stem.ps/podcast/liefery/2019/04/14/podcast-interview-digitale-gruender-part-2.html<p>Here is the second part of my podcast interview (in German) with <a href="https://simon-frey.eu">Simon
Frey</a> of Digitale Gründer
Podcast. The podcast is no longer active, but you can still find it cached on
<a href="https://castro.fm/episode/816TNF">Castro</a> or listen in the embedded player below.</p>
<p>In this part we talk about how we work and develop software at
<a href="https://www.liefery.com">liefery</a>, how we apply agile ideas to continuously
grow our own develop tune our development process, about working remote-first
and how we like working in groups of three.</p>
<p>I hope you enjoy listening!</p>
<audio controls="">
<source src="/audio/digitale-gruender-podcast-2.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>
<h2 id="references">References</h2>
<ul>
<li><a href="https://castro.fm/episode/2eWmg7">Listen with Castro</a></li>
</ul>
http://example.com/podcast/liefery/2019/04/02/podcast-interview-digitale-gruender-part-1Interview on Digitale Gründer Podcast (Part 1)2019-04-02T15:00:00+00:002019-04-02T15:00:00+00:00Simon Stemplingerhttp://stem.ps/podcast/liefery/2019/04/02/podcast-interview-digitale-gruender-part-1.html<p>Last month I got interviewed (in German) by <a href="https://simon-frey.eu">Simon Frey</a>
of Digitale Gründer Podcast. The podcast is no longer active, but you can still find it cached on
<a href="https://castro.fm/episode/816TNF">Castro</a> or listen in the embedded player below.</p>
<p>We talked about how CS doesn’t teach programming, the joy of building software
products as well as past and current projects, especially the challenges we are
solving at <a href="https://www.liefery.com">liefery.com</a>.</p>
<p>A second episode will be published soon.</p>
<p>Simon Frey was a fantastic podcast host and it was a fun experience to be
part of the episode.</p>
<p>I hope you enjoy listening!</p>
<audio controls="">
<source src="/audio/digitale-gruender-podcast-1.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>
<h2 id="references">References</h2>
<ul>
<li><a href="https://castro.fm/episode/816TNF">Listen with Castro</a></li>
</ul>
http://example.com/liefery/elastic/kibana/2019/03/29/using-elastic-stack-at-lieferyUsing the Elastic Stack at Liefery2019-03-29T15:00:00+00:002019-03-29T15:00:00+00:00Simon Stemplingerhttp://stem.ps/liefery/elastic/kibana/2019/03/29/using-elastic-stack-at-liefery.html<p>In a recently published <a href="https://www.elastic.co/blog/using-the-elastic-stack-for-business-intelligence-at-liefery">interview blog post</a> I talk with Meline Keoxay about how the <a href="http://engineering.liefery.com/">engineering team</a> at Liefery uses the <a href="https://www.elastic.co/elk-stack">ELK Stack</a> for centralized, structured logging and how a whole business intelligence solution fell out of it as a very nice unintended side effect.</p>
<p>We cover how we started to look for a better logging solution for our backend applications and ended up with a multipurpose reporting and data visualization tool that both our engineering and our business departments are using every day.</p>
<p>Enjoy reading!</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://www.elastic.co/blog/using-the-elastic-stack-for-business-intelligence-at-liefery">https://www.elastic.co/blog/using-the-elastic-stack-for-business-intelligence-at-liefery</a></li>
</ul>
http://example.com/rails/technical-debt/2015/11/28/fighting-technical-debt-with-hatsFighting Technical Debt... with Hats!2015-11-28T15:00:00+00:002015-11-28T15:00:00+00:00Simon Stemplingerhttp://stem.ps/rails/technical-debt/2015/11/28/fighting-technical-debt-with-hats.html<p>It happens on the best projects and to the best teams. Eventually every code base accumulates some form of technical debt. It can come from consciously prioritizing short term output over long term maintainability, from less conscious neglect or simply from outgrowing an original architecture design. Despite its mostly negative connotation taking on technical debt can sometimes be a sensible idea if it allows you to ship an important release earlier and make your users happier.</p>
<p>Regardless of whether you accumulated your technical debt deliberately or recklessly, the debt must eventually be repaid or your team’s productivity will start to spiral down out of control. The internet is full of good advice on how to fight technical debt by writing refactoring tickets, doing code reviews, etc… There’s even a lot of advice on how to sell it to your non-technical manager. The trouble with lots of these approaches is that they rely on the same process that made the technical debt appear in the first place. The chances are that the same pressures that made the it appear can thwart your attempts of repaying it.</p>
<p>Here I’d like to introduce a different way we recently tried out at <a href="https://www.liefery.com">Liefery</a> and it’s a slightly more playful one.</p>
<div style="float:right; border: 1px solid #ddd; padding: 6px; margin-left: 20px;">
<div><img src="/images/fighting-technical-debt/tessi-rainbow.jpg" width="200" height="244" /></div>
<p style="font-size: 0.8em; font-weight: bold; width: 200px;">Tessi proudly wearing the rainbow hat</p>
</div>
<p><strong>We bought some hats…</strong></p>
<p>We now have 2 special hats that are passed around the team and I don’t mean figurative hats, but actual real literal hats. Silly hats to be exact.</p>
<p>We currently have the <em>“performance shark”</em> hat and the <em>“rainbow”</em> hat and they work like this:</p>
<p>Whoever gets the <em>“performance shark”</em> hat gets half a day of our one week iteration to make some part of our platform work faster.</p>
<p>Whoever gets the <em>“rainbow”</em> hat gets half a day of the iteration to “make the project a better place”. The definition is purposely vague and it could mean making a part of our codebase nicer to work on, improving our tooling, automating day to day tasks, contributing a change to a dependency we use, trying out an interesting feature that’s not on the backlog, etc., as long as it benefits the team or the product.</p>
<div style="float:left; border: 1px solid #ddd; padding: 6px; margin-right: 20px; margin-bottom: 20px;">
<div><img src="/images/fighting-technical-debt/tobi-edward.jpg" width="250" height="281" /></div>
<p style="font-size: 0.8em; font-weight: bold; width: 250px;">Tobi and Edward combining the power of both hats</p>
</div>
<p>The important part of owning a hat is that the hat-time that comes with it is self-directed. There is no prioritized ToDo list for a hat wearer. There only has to be a positive outcome for the rest of the team at the end of the hat-time. Self-direction brings with it additional motivation and provides a welcome change from the normal feature-driven or business-driven development tasks and makes owning a hat a privilege rather than a chore. It balances the often short term interests of the business (“I want this feature in production yesterday”) with the typically more long term interests of the development team (“I want this codebase to be fun to work on”).</p>
<div style="clear: both;" />
<div style="float:right; border: 1px solid #ddd; padding: 6px; margin-left: 20px; margin-bottom: 20px;">
<div><img src="/images/fighting-technical-debt/tobi-simon.jpg" width="300" height="182" /></div>
<p style="font-size: 0.8em; font-weight: bold; width: 300px;">Our iteration meetings are now way more professional</p>
</div>
<p>In every iteration meeting the team decides who should get the hats for the next iteration. We typically balance this so that everyone gets an equal share of hat-time, but they can also be given out for special achievements like finishing a big story, solving a difficult problem or to compensate for taking on an undesirable task.</p>
<div style="clear: both;" />
<div style="float:left; border: 1px solid #ddd; padding: 6px; margin-right: 20px; margin-bottom: 20px;">
<div><img src="/images/fighting-technical-debt/manuel-rainbow.jpg" width="200" height="243" /></div>
<p style="font-size: 0.8em; font-weight: bold; width: 200px;">Manuel making the world a better place</p>
</div>
<p>And obviously, <strong>while working on hat-time… one has to wear the hat.</strong></p>
<div style="clear: both;" />
<div style="float:right; border: 1px solid #ddd; padding: 6px; margin-left: 20px; margin-bottom: 20px;">
<div><img src="/images/fighting-technical-debt/simon-shark.jpg" width="200" height="266" /></div>
<p style="font-size: 0.8em; font-weight: bold; width: 200;">Shark time!</p>
</div>
<p>If your team also finds it difficult to fight technical debt I’d encourage you to try this out too. It’s a very fun and playful way to improve the quality of your code and balance your team’s short-term and long-term interests. And if you do… I’d love to see your hat-pictures. Send them to me <a href="mailto:simon@stem.ps">by email</a> and I will publish them in a gallery if I get enough.</p>
<div style="clear: both;" />
<h2 id="references">References</h2>
<ul>
<li><a href="http://martinfowler.com/bliki/TechnicalDebt.html">http://martinfowler.com/bliki/TechnicalDebt.html</a></li>
<li><a href="http://martinfowler.com/bliki/TechnicalDebtQuadrant.html">http://martinfowler.com/bliki/TechnicalDebtQuadrant.html</a></li>
<li><a href="http://blog.codinghorror.com/paying-down-your-technical-debt/">http://blog.codinghorror.com/paying-down-your-technical-debt/</a></li>
<li><a href="http://www.c2.com/cgi/wiki?TechnicalDebt">http://www.c2.com/cgi/wiki?TechnicalDebt</a></li>
<li><a href="http://amzn.to/1Rd5xOM">Rainbow hat on Amazon</a></li>
<li><a href="http://amzn.to/1Omo7n4">Shark hat on Amazon</a></li>
</ul>
http://example.com/2015/11/27/configuring-email-for-development-and-staging-rails-environmentsSafe Emailing in Rails Development and Staging Environments2015-11-27T14:14:03+00:002015-11-27T14:14:03+00:00http://stem.ps/2015/11/27/configuring-email-for-development-and-staging-rails-environments.html<p>Most Rails Apps send emails of some sort. Users receive welcome emails,
passwort reset emails, order confirmation or other transactional mails and
marketing emails of differnet flavours. Sending Emails often requires thorough
manual testing with different email clients to make sure they look like they
are supposed to. And while testing we must to be extra sure we’re not
accidentally sending emails to real people.</p>
<p>Rails supports a number of different ways of dealing with emails out of the
box. You can configure ActionMailer to deliver Emails to:</p>
<ul>
<li>a local sendmail server</li>
<li>an SMTP server</li>
<li>a local file</li>
<li>nowhere (ignore the email)</li>
</ul>
<p>Other popular third party tools are the
<a href="https://github.com/ryanb/letter_opener">letter_opener</a> gem by Ryan Bates which
opens any email in the browser as they are sent and
<a href="http://mailcatcher.me/">mailcatcher</a>, which runs a local SMTP server and mail
viewer web-app.</p>
<p>While these options are very useful, if find that none of them are giving me the
close to real world testing scenario of testing emails in actual email clients
I’m looking for while making sure that no emails get accidentally sent to real
people.</p>
<p>The danger of emails escaping your development or staging environment is
especially big of you use snapshots of production data to populate your
development and staging databases.</p>
<h2 id="my-preferred-setup">My Preferred Setup</h2>
<p>I found that the following setup works best for me:</p>
<ul>
<li>in the <strong>development</strong> environment all emails are <strong>redirected to my personal email account</strong></li>
<li>in the <strong>staging</strong> environment <strong>emails are only sent to a whitelisted set of domains</strong></li>
</ul>
<p>This means that while developing on my local machine, I get to see every email that is sent. I get to see the email in <em>in the wild</em> that is in an actual email client. I can also use different email clients or web-clients to test the layout. This gives me a more realistic way of testing the email than just in my browser where they layout can look quite different to an email client.</p>
<p>On staging I typically whitelist the email domain(s) of the involved development companies or private domains of individual developers. This way all developers, QA and business people can see how the emails look like, but still no emails get sent to actual customers.</p>
<h2 id="gems">Gems</h2>
<p>There are a couple of guides and blog posts about how to set this up manually. Or you can use a gem to help you with the setup:</p>
<ul>
<li>A popular solution is Myron Marston’s gem <a href="https://github.com/myronmarston/mail_safe">mail_safe</a></li>
<li>I extracted a similar solution from my projects in the <a href="https://github.com/stemps/mailsafe">mailsafe</a> gem (sorry for the name clash… I didn’t notice until a while after I published it)</li>
</ul>
<p>Here are the instructions to work with the <a href="https://github.com/stemps/mailsafe">mailsafe</a> gem:</p>
<p>To install it add</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="n">gem</span> <span class="s1">'mailsafe'</span> </code></pre></figure>
<p>to your <code class="language-plaintext highlighter-rouge">Gemfile</code> and run</p>
<figure class="highlight"><pre><code class="language-text" data-lang="text">bundle install </code></pre></figure>
<p>Then add the following lines to your <code class="language-plaintext highlighter-rouge">development.rb</code> file:</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="no">Mailsafe</span><span class="p">.</span><span class="nf">setup</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">override_receiver</span> <span class="o">=</span> <span class="s2">"your-email-address@example.com"</span>
<span class="n">config</span><span class="p">.</span><span class="nf">prefix_email_subject_with_rails_env</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">end</span></code></pre></figure>
<p>and the following lines to your <code class="language-plaintext highlighter-rouge">staging.rb</code> file:</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="no">Mailsafe</span><span class="p">.</span><span class="nf">setup</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">allowed_domain</span> <span class="o">=</span> <span class="s2">"devco.com, clientco.com"</span>
<span class="n">config</span><span class="p">.</span><span class="nf">prefix_email_subject_with_rails_env</span> <span class="o">=</span> <span class="kp">true</span>
<span class="k">end</span></code></pre></figure>
<p>And you will never have to worry about escaping emails again.</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://github.com/ryanb/letter_opener">letter_opener</a></li>
<li><a href="http://mailcatcher.me/">mailcatcher</a></li>
<li><a href="https://github.com/myronmarston/mail_safe">mail_safe</a></li>
<li><a href="https://github.com/stemps/mailsafe">mailsafe</a></li>
</ul>
http://example.com/rails/2015/01/25/ruby-gotcha-toplevel-constant-referenced-byTIL: "warning: toplevel constant X referenced by Y"2015-01-25T14:50:00+00:002015-01-25T14:50:00+00:00Simon Stemplingerhttp://stem.ps/rails/2015/01/25/ruby-gotcha-toplevel-constant-referenced-by.html<p>We ran into an interesting issue recently. After a seemingly unrelated
change a large number of tests failed with messages saying <code class="language-plaintext highlighter-rouge">warning: toplevel
constant X referenced by Y</code>.</p>
<h2 id="the-situation">The Situation</h2>
<p>For a logistics platform we needed multiple JSON-APIs (one for <strong>clients</strong>,
one for <strong>couriers</strong>). Both are using different data formats and therefore require
separate JSON serializers (we are using
<a href="https://github.com/rails-api/active_model_serializers">ActiveModel::Serializers</a>).</p>
<p>The serializers are namespaced and have common structures extracted into a
superclass. It looks something like this:</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="k">class</span> <span class="nc">ShipmentSerializer</span>
<span class="c1"># contains common data structures</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">Client::ShipmentSerializer</span> <span class="o"><</span> <span class="no">ShipmentSerializer</span>
<span class="c1"># contains data structures specific for the client API</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">Courier::ShipmentSerializer</span> <span class="o"><</span> <span class="no">ShipmentSerializer</span>
<span class="c1"># contains data structures specific for the courier API</span>
<span class="k">end</span></code></pre></figure>
<p>This worked fine until one day several tests failed unexpectedly. The data
returned by the serializers was wrong and we found the following warnings in
the test output:</p>
<figure class="highlight"><pre><code class="language-text" data-lang="text">warning: toplevel constant ShipmentSerializer referenced by <some class>
warning: toplevel constant ShipmentSerializer referenced by <some other class>
...</code></pre></figure>
<p>After some digging we identified the problem was that the code that
referenced either <code class="language-plaintext highlighter-rouge">Client::ShipmentSerializer</code> or <code class="language-plaintext highlighter-rouge">Courier::ShipmentSerializer</code>
suddenly got <em>handed</em> the superclass <code class="language-plaintext highlighter-rouge">ShipmentSerializer</code> by Ruby instead. It
did not cause any runtime errors but did result in incorrectly serialized data.</p>
<p>How could that be? The referencing code clearly references the namespaced class
<code class="language-plaintext highlighter-rouge">Courier::ShipmentSerializer</code> but Ruby gave it a different class. Similar in
name though, but clearly different. After all that’s what namespacing is for,
isn’t it?</p>
<h2 id="namespacing-doesnt-work-as-you-believe">Namespacing doesn’t work as you believe</h2>
<p>Turns out… namespacing in Ruby works differently than most of us would
expect. <strong>When you write <code class="language-plaintext highlighter-rouge">Foo::Bar</code> in Ruby, it does not mean <code class="language-plaintext highlighter-rouge">Bar</code> within
namespace <code class="language-plaintext highlighter-rouge">Foo</code>, but rather <code class="language-plaintext highlighter-rouge">Bar</code> as “seen” from <code class="language-plaintext highlighter-rouge">Foo</code></strong> <sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup>. And it turns out
that modules and classes differ in what they can “<em>see</em>”. As long as <code class="language-plaintext highlighter-rouge">Foo</code> is
defined as a module this works well. However, in the case that <code class="language-plaintext highlighter-rouge">Foo</code> is a class
suddenly that class will <em>see</em> other toplevel constants as well.</p>
<p>You can easily try out the difference by comparing the output of the following
2 commands:</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nv">$ </span>ruby <span class="nt">-e</span> <span class="s1">'module Foo; end; Foo::String'</span>
<span class="nt">-e</span>:1:in <span class="sb">`</span><main><span class="s1">': uninitialized constant Foo::String (NameError)</span></code></pre></figure>
<p>As expected, we get an error because there is no constant <code class="language-plaintext highlighter-rouge">String</code> within the
module <code class="language-plaintext highlighter-rouge">Foo</code>.</p>
<figure class="highlight"><pre><code class="language-bash" data-lang="bash"><span class="nv">$ </span>ruby <span class="nt">-e</span> <span class="s1">'class Foo; end; Foo::String'</span>
<span class="nt">-e</span>:1: warning: toplevel constant String referenced by Foo::String</code></pre></figure>
<p>As you might have not have expected, Ruby has no problem referencing
<code class="language-plaintext highlighter-rouge">Foo::String</code> if <code class="language-plaintext highlighter-rouge">Foo</code> is a class even if it doesn’t have a constant <code class="language-plaintext highlighter-rouge">String</code>
within it. It can “<em>see</em>” the toplevel constant <code class="language-plaintext highlighter-rouge">::String</code> and uses it instead.</p>
<p>You can even string together a whole list of class constants and Ruby will
always fall back to the toplevel classes (albeit with warnings):</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="n">irb</span><span class="p">(</span><span class="n">main</span><span class="p">):</span><span class="mo">001</span><span class="p">:</span><span class="mi">0</span><span class="o">></span> <span class="no">Hash</span><span class="o">::</span><span class="no">Array</span><span class="o">::</span><span class="no">String</span><span class="o">::</span><span class="no">File</span>
<span class="p">(</span><span class="n">irb</span><span class="p">):</span><span class="mi">1</span><span class="p">:</span> <span class="ss">warning: </span><span class="n">toplevel</span> <span class="n">constant</span> <span class="no">Array</span> <span class="n">referenced</span> <span class="n">by</span> <span class="no">Hash</span><span class="o">::</span><span class="no">Array</span>
<span class="p">(</span><span class="n">irb</span><span class="p">):</span><span class="mi">1</span><span class="p">:</span> <span class="ss">warning: </span><span class="n">toplevel</span> <span class="n">constant</span> <span class="no">String</span> <span class="n">referenced</span> <span class="n">by</span> <span class="no">Array</span><span class="o">::</span><span class="no">String</span>
<span class="p">(</span><span class="n">irb</span><span class="p">):</span><span class="mi">1</span><span class="p">:</span> <span class="ss">warning: </span><span class="n">toplevel</span> <span class="n">constant</span> <span class="no">File</span> <span class="n">referenced</span> <span class="n">by</span> <span class="no">String</span><span class="o">::</span><span class="no">File</span>
<span class="o">=></span> <span class="no">File</span></code></pre></figure>
<p>The good news is that as long as the correctly namespaced class is defined, the
correct class is used:</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="k">class</span> <span class="nc">Foo</span><span class="p">;</span> <span class="k">end</span>
<span class="k">class</span> <span class="nc">Bar</span><span class="p">;</span> <span class="k">end</span>
<span class="no">Foo</span><span class="o">::</span><span class="no">Bar</span> <span class="c1"># => warning: toplevel constant Bar referenced by Foo::Bar</span>
<span class="k">class</span> <span class="nc">Foo::Bar</span><span class="p">;</span> <span class="k">end</span>
<span class="no">Foo</span><span class="o">::</span><span class="no">Bar</span> <span class="c1"># => returns correct class Foo::Bar</span></code></pre></figure>
<p>How is this a problem in our original case then? Enter Rails…</p>
<h2 id="rails-lazy-auto-loading">Rails’ lazy auto-loading</h2>
<p>It all works fine, as one can see in the previous example, when all
classes are loaded. However this is not always the case in Rails <em>development</em> and
<em>test</em> environments by default. Here Rails only loads the classes when they are
needed for performance reasons.</p>
<p>To achieve this, Rails overwrites <code class="language-plaintext highlighter-rouge">Module#const_missing</code> to know when a new class
might need to be loaded. It then guesses the filename from the constant name,
loads the class and passes on execution as if nothing ever happened. <strong>Rails
autoloading relies on <code class="language-plaintext highlighter-rouge">#const_missing</code> being triggered and in our case this
does not happen because Ruby has found the toplevel constant instead.</strong> In our
case the correct class is never loaded and execution continues with a wrong
class. Even worse, whether or not it fails can depend on the order in which the
classes are auto-loaded, adding a non-deterministic component to make debugging
extra fun.</p>
<p>But let’s get back to our original example with the different JSON serializers.
Our issue here was that we had namespaced serializers, but also an ActiveRecord
model with the same name as one of the namespaces:</p>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="k">class</span> <span class="nc">ShipmentSerializer</span>
<span class="c1"># contains common data structures</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">Client::ShipmentSerializer</span> <span class="o"><</span> <span class="no">ShipmentSerializer</span>
<span class="c1"># contains data structures specific for the client API</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">Courier::ShipmentSerializer</span> <span class="o"><</span> <span class="no">ShipmentSerializer</span>
<span class="c1"># contains data structures specific for the courier API</span>
<span class="k">end</span>
<span class="k">class</span> <span class="nc">Courier</span> <span class="o"><</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span>
<span class="c1"># ActiveRecord model</span>
<span class="k">end</span></code></pre></figure>
<p>Now when some code tries to access <code class="language-plaintext highlighter-rouge">Courier::ShipmentSerializer</code> it would “ask”
<code class="language-plaintext highlighter-rouge">Courier</code> for the <code class="language-plaintext highlighter-rouge">ShipmentSerializer</code> constant. if
<code class="language-plaintext highlighter-rouge">Courier::ShipmentSerializer</code> is already auto-loaded everything works fine, but
if it is not <code class="language-plaintext highlighter-rouge">Courier</code> would also look in the toplevel namespace for
<code class="language-plaintext highlighter-rouge">::ShipmentSerializer</code> and find the superclass if it was already loaded. The
code continues, but uses the wrong serializer and produces incorrect data.</p>
<h2 id="the-solution">The Solution</h2>
<p>While there is no real solution to this, there are a couple of workarounds:</p>
<ol>
<li>Rename the class <code class="language-plaintext highlighter-rouge">Courier</code></li>
<li>Make the class <code class="language-plaintext highlighter-rouge">Courier</code> a module (might not be an option)</li>
<li>Rename the namespace <code class="language-plaintext highlighter-rouge">Courier</code></li>
<li>Introduce an additional root namespace, e.g.
<code class="language-plaintext highlighter-rouge">Serializer::Courier::ShipmentSerializer</code></li>
<li>Explicitly <code class="language-plaintext highlighter-rouge">require 'courier/shipments_controller'</code> where it is used</li>
<li>Disable lazy loading</li>
</ol>
<p>We decided on <em>4.</em> in our case but this is very much case dependent. In the
future I will try to avoid using toplevel namespaces that are the same as
existing classes or that could be likely candidates for class names in the
future.</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://makandracards.com/makandra/20633-ruby-constant-lookup-the-good-the-bad-and-the-ugly">https://makandracards.com/makandra/20633-ruby-constant-lookup-the-good-the-bad-and-the-ugly</a></li>
<li><a href="http://urbanautomaton.com/blog/2013/08/27/rails-autoloading-hell/">http://urbanautomaton.com/blog/2013/08/27/rails-autoloading-hell/</a></li>
<li><a href="https://github.com/rails/rails/issues/6931#issuecomment-6703968">https://github.com/rails/rails/issues/6931#issuecomment-6703968</a></li>
</ul>
<hr />
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:1" role="doc-endnote">
<p><a href="https://makandracards.com/makandra/20633-ruby-constant-lookup-the-good-the-bad-and-the-ugly">https://makandracards.com/makandra/20633-ruby-constant-lookup-the-good-the-bad-and-the-ugly</a> <a href="#fnref:1" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>
http://example.com/2015/01/24/welcome-to-my-blogWelcome to my Blog!2015-01-24T14:14:03+00:002015-01-24T14:14:03+00:00http://stem.ps/2015/01/24/welcome-to-my-blog.html<p>After years of thinking that “<em>blogging is just not for me</em>” I am finally
giving it a shot.</p>
<p>I guess I have always considered myself as not extroverted enough to write
publicly. But recently I realized that despite taking an awful lot of
information and advice from other people’s writing, I am not giving anything
back at all. So I decided to stop being a pure ‘leecher’ and begin ‘seeding’ a
bit as well in an attempt to be a better citizen in the software development
community.</p>
<p>But there’s also another, much less altruistic reason and that is that writing
really forces you to think things through to a much deeper level that one would
normally do. You can’t BS your text editor as well as you can BS
yourself. I hope that building a habit to write will end up training me to have
better informed opinions and be better at getting them across which - I am
convinced - is an extremely helpful but typically underrated skill among
software developers.</p>
<blockquote>
<p>The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer.</p>
<footer> Ward Cunningham</footer>
</blockquote>
<p>I will likely be writing about a combination of the following topics:</p>
<ul>
<li>Ruby and Ruby on Rails development</li>
<li>Software development in general</li>
<li>Methodologies and agile stuff</li>
<li>Tools, Hacks, Gizmos and other nerdy things</li>
<li>and maybe some random food / cooking stuff thrown in</li>
</ul>
<p>So, bear with me while I make my first attempts at writing. Feeld free to give
me feedback to <a href="https://twitter.com/stemps">@stemps</a> or by <a href="mailto:simon@stem.ps">email</a>.</p>