<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Refactoring on ilikeorangutans</title><link>https://kuelzer.ca/tags/refactoring/</link><description>Recent content in Refactoring on ilikeorangutans</description><generator>Hugo</generator><language>en</language><copyright>© 2026 Jakob Külzer</copyright><lastBuildDate>Sun, 12 Apr 2026 14:27:24 -0400</lastBuildDate><atom:link href="https://kuelzer.ca/tags/refactoring/index.xml" rel="self" type="application/rss+xml"/><item><title>Give Me Smarter Objects</title><link>https://kuelzer.ca/posts/2018/06/18/give-me-smarter-objects/</link><pubDate>Mon, 18 Jun 2018 21:20:31 -0400</pubDate><guid>https://kuelzer.ca/posts/2018/06/18/give-me-smarter-objects/</guid><description>&lt;p&gt;A coding exercise I do once in a while is writing &lt;a href="https://en.wikipedia.org/wiki/Battleship_(game)"&gt;Battleship&lt;/a&gt;. It&amp;rsquo;s a
fun little exercise, comes with a slew of interesting decisions, and every once in a while I do this exercise with a
candidate as part of the interview process. It&amp;rsquo;s always exciting to see what other developers come up with. Today I was
doing the exercise and I contemplated on the &lt;em&gt;primitive obsession&lt;/em&gt; code smell that always seems to creep into my code
and saw a beautiful way to apply the &lt;em&gt;extract class&lt;/em&gt; refactoring that very succinctly shows how nice object oriented
programming can be.&lt;/p&gt;</description></item><item><title>gorename and invalid expression</title><link>https://kuelzer.ca/posts/2015/10/23/gorename-and-invalid-expression/</link><pubDate>Fri, 23 Oct 2015 13:59:40 -0400</pubDate><guid>https://kuelzer.ca/posts/2015/10/23/gorename-and-invalid-expression/</guid><description>&lt;p&gt;This took me longer to figure out than I care to admit, so here&amp;rsquo;s the solution.&lt;/p&gt;
&lt;p&gt;The issue comes up when trying to use &lt;a href="https://godoc.org/golang.org/x/tools/cmd/gorename"&gt;gorename&lt;/a&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; gorename -from &lt;span class="s2"&gt;&amp;#34;github.com/ilikeorangutans/foo&amp;#34;&lt;/span&gt;.MyType -to &lt;span class="s1"&gt;&amp;#39;MyBetterType&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;gorename: -from &amp;#34;github.com/ilikeorangutans/foo.MyType&amp;#34;: invalid expression
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Even though the &lt;code&gt;from&lt;/code&gt; query looks normal, &lt;code&gt;gorename&lt;/code&gt; just refuses to work. However the issue is not so much with &lt;code&gt;gorename&lt;/code&gt; but rahter my shell, zsh. Turns out properly escaping your from query, fixes the issue:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; gorename -from &lt;span class="s1"&gt;&amp;#39;&amp;#34;github.com/ilikeorangutans/foo&amp;#34;.MyType&amp;#39;&lt;/span&gt; -to &lt;span class="s1"&gt;&amp;#39;MyBetterType&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Renamed 15 occurrences in 5 files in 1 package.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Notice the single quotes around the entire &lt;code&gt;from&lt;/code&gt; parameter.&lt;/p&gt;</description></item></channel></rss>