<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Dataclass on cassiobotaro</title><link>https://cassiobotaro.dev/en/tags/dataclass/</link><description>Recent content in Dataclass on cassiobotaro</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sat, 25 Jul 2026 13:06:19 -0300</lastBuildDate><atom:link href="https://cassiobotaro.dev/en/tags/dataclass/index.xml" rel="self" type="application/rss+xml"/><item><title>Fully comparable objects with a single method</title><link>https://cassiobotaro.dev/en/posts/comparable-objects/</link><pubDate>Wed, 01 Jul 2026 00:00:00 +0000</pubDate><guid>https://cassiobotaro.dev/en/posts/comparable-objects/</guid><description>&lt;h2 id="the-problem"&gt;
 The problem
 &lt;a class="heading-link" href="#the-problem"&gt;
 &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;
 &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;
 &lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;For an object to respond to &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;lt;=&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;gt;=&lt;/code&gt;, &lt;code&gt;==&lt;/code&gt; and &lt;code&gt;!=&lt;/code&gt;, Python expects you to implement &lt;code&gt;__lt__&lt;/code&gt;, &lt;code&gt;__le__&lt;/code&gt;, &lt;code&gt;__gt__&lt;/code&gt;, &lt;code&gt;__ge__&lt;/code&gt;, &lt;code&gt;__eq__&lt;/code&gt; and &lt;code&gt;__ne__&lt;/code&gt;. That is six nearly identical methods, tedious to write and easy to leave inconsistent (one says &lt;code&gt;a &amp;lt; b&lt;/code&gt; and another disagrees).&lt;/p&gt;
&lt;h2 id="the-tip"&gt;
 The tip
 &lt;a class="heading-link" href="#the-tip"&gt;
 &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;
 &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;
 &lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Two pieces cover everything:&lt;/p&gt;</description></item><item><title>The Money Object</title><link>https://cassiobotaro.dev/en/posts/the-money-object/</link><pubDate>Sun, 01 Mar 2026 00:00:00 +0000</pubDate><guid>https://cassiobotaro.dev/en/posts/the-money-object/</guid><description>&lt;p&gt;&lt;img src="https://cassiobotaro.dev/images/dinheiro.png" alt="Money"&gt;&lt;/p&gt;
&lt;h2 id="the-story"&gt;
 The Story
 &lt;a class="heading-link" href="#the-story"&gt;
 &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;
 &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;
 &lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;A while ago I took part in the hiring process of a fairly well known purple bank. I did not get in, but I got valuable feedback about the code I wrote. Putting that feedback together with things I learned afterwards, I decided to revisit the challenge and improve the implementation.&lt;/p&gt;
&lt;p&gt;One of the most significant improvements was creating a &lt;code&gt;Money&lt;/code&gt; object, based on the pattern of the same name described by Martin Fowler in &lt;em&gt;Patterns of Enterprise Application Architecture&lt;/em&gt; (PEAA).&lt;/p&gt;</description></item></channel></rss>