<?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 Brian Faust</title><link>https://wimdy.works/tags/refactoring/</link><description>Recent content in Refactoring on Brian Faust</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Mon, 01 Jan 0001 00:00:00 +0000</lastBuildDate><atom:link href="https://wimdy.works/tags/refactoring/rss.xml" rel="self" type="application/rss+xml"/><item><title>Design Becomes Valuable When the Next Change Arrives</title><link>https://wimdy.works/thoughts/design-becomes-valuable-when-the-next-change-arrives/</link><pubDate>Tue, 01 Dec 2020 00:00:00 +0000</pubDate><guid>https://wimdy.works/thoughts/design-becomes-valuable-when-the-next-change-arrives/</guid><description>&lt;p&gt;One migration removed four vendor packages. Two payment drivers, their client
interfaces, and their factory interfaces did not change; the concrete clients
changed substantially.&lt;/p&gt;
&lt;p&gt;Two application controllers were less fortunate. They had constructed a
vendor connection directly to manage webhooks, so the replacement had to add a
small webhook-management role and move the remote protocol behind it.&lt;/p&gt;
&lt;p&gt;The same migration produced both results: some earlier seams absorbed the
change, while other paths showed exactly where the vendor had leaked through.
That tells us more than declaring the design “clean.” A design makes a
prediction about future change, and the next real change tells us which parts
of that prediction were right.&lt;/p&gt;</description></item><item><title>A Service Class Can Become a Procedural Junk Drawer</title><link>https://wimdy.works/thoughts/a-service-class-can-become-a-procedural-junk-drawer/</link><pubDate>Fri, 01 May 2020 00:00:00 +0000</pubDate><guid>https://wimdy.works/thoughts/a-service-class-can-become-a-procedural-junk-drawer/</guid><description>&lt;p&gt;A web controller contained nearly two thousand lines of shipment creation.
Moving those lines into a class described as a creation orchestrator sounded
like an architectural improvement.&lt;/p&gt;
&lt;p&gt;The new class contained nearly two thousand lines of shipment creation.&lt;/p&gt;
&lt;p&gt;The first move was still useful. It removed the procedure from the HTTP
adapter. What it did not do was make the procedure cohesive. Validation,
payment gating, draft persistence, provider booking, tracking, document
creation, response mapping, notifications, and indexing still changed inside
one file. &lt;code&gt;Service&lt;/code&gt; and &lt;code&gt;orchestrator&lt;/code&gt; are roles only when the code earns those
names. Otherwise they are folders for procedures we no longer want in
controllers.&lt;/p&gt;</description></item><item><title>Boolean Parameters Hide Different Operations</title><link>https://wimdy.works/thoughts/boolean-parameters-hide-different-operations/</link><pubDate>Sun, 01 Mar 2020 00:00:00 +0000</pubDate><guid>https://wimdy.works/thoughts/boolean-parameters-hide-different-operations/</guid><description>&lt;p&gt;This method call is legal:&lt;/p&gt;
&lt;figure class="code-figure"&gt;
 &lt;div class="code-block" data-copy-code&gt;
 &lt;button class="copy-code" type="button" aria-label="Copy code"&gt;copy&lt;/button&gt;&lt;span class="sr-only" data-copy-status role="status" aria-live="polite"&gt;&lt;/span&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;$exporter&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$accountId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
 &lt;/div&gt;
&lt;/figure&gt;
&lt;p&gt;It is also semantically wrong.&lt;/p&gt;
&lt;p&gt;The first boolean in the exporter meant “source billing details from
the effective payer.” The payload still targeted the original account and kept
that account&amp;rsquo;s operational fields. The second boolean meant “the source&amp;rsquo;s
billing mode is an authoritative instruction.”&lt;/p&gt;
&lt;p&gt;An effective-payer export described who pays; it was not allowed to change the
original account&amp;rsquo;s billing mode. The &lt;code&gt;true, true&lt;/code&gt; combination therefore had to
be neutralized by a later guard.&lt;/p&gt;</description></item><item><title>A Class Name Should Describe a Role</title><link>https://wimdy.works/thoughts/a-class-name-should-describe-a-role/</link><pubDate>Wed, 01 Jan 2020 00:00:00 +0000</pubDate><guid>https://wimdy.works/thoughts/a-class-name-should-describe-a-role/</guid><description>&lt;p&gt;Several classes in one application had almost the same shape. Each extended a
connection manager, read named configuration, and delegated object creation to
a factory. One managed payment gateways, another rating clients, and another
booking clients.&lt;/p&gt;
&lt;p&gt;The shared abstraction made their code look alike. Their callers were asking
different questions.&lt;/p&gt;
&lt;p&gt;Payment callers needed a gateway with a given name. Rating callers sometimes
needed to decide which connection matched a shipment. Booking callers selected
connections from different rules for creating, collecting, and cancelling,
then assembled operation-specific services around the result.&lt;/p&gt;</description></item><item><title>Parallel Implementations Are Not a Replacement Seam</title><link>https://wimdy.works/thoughts/parallel-implementations-are-not-a-replacement-seam/</link><pubDate>Mon, 01 Apr 2019 00:00:00 +0000</pubDate><guid>https://wimdy.works/thoughts/parallel-implementations-are-not-a-replacement-seam/</guid><description>&lt;p&gt;An old shipping integration and its proposed replacement lived beside each
other. Both had an interface, a driver, request builders, and tests. From the
directory tree, that looked like a seam.&lt;/p&gt;
&lt;p&gt;When the replacement was finally made canonical, the change still crossed
dozens of files. The old interface disappeared, the new one moved, the
canonical driver changed its pickup and shipment flows, and a parallel driver
tree was deleted. Follow-up work then corrected a request shape and added
serialization tests.&lt;/p&gt;</description></item><item><title>A Characterization Suite Is Scoped to a Change</title><link>https://wimdy.works/thoughts/a-characterization-suite-is-scoped-to-a-change/</link><pubDate>Fri, 01 Feb 2019 00:00:00 +0000</pubDate><guid>https://wimdy.works/thoughts/a-characterization-suite-is-scoped-to-a-change/</guid><description>&lt;p&gt;A booking endpoint had more than thirty characterization cases. They covered
successful bookings, validation failures, wallet rules, locks, pending work,
email routing, and several provider response shapes.&lt;/p&gt;
&lt;p&gt;The next refactor removed one ambient HTTP dependency from the booking
services. The suite looked broad enough. It was not broad in the direction of
the change.&lt;/p&gt;
&lt;p&gt;One service read the global request to persist the original payload. Replacing
that read with the existing booking data object would keep ordinary responses
green while silently storing normalized values where operators expected the
raw input. The suite already protected a test-mode short circuit. It needed a
new case for the two representations.&lt;/p&gt;</description></item></channel></rss>