<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Software Design on Nalar</title>
    <link>https://nalar.dev/tags/software-design/</link>
    <description>Recent content in Software Design on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 01 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/tags/software-design/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Design Value Objects with Python Dataclasses</title>
      <link>https://nalar.dev/design-value-objects-with-python-dataclasses/</link>
      <pubDate>Tue, 01 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/design-value-objects-with-python-dataclasses/</guid>
      <description>&lt;p&gt;Python dictionaries are convenient for passing a few values around, but they become fragile when a value has invariants or behavior that deserves a name. &lt;code&gt;dataclasses&lt;/code&gt; can express small domain value objects without repetitive constructors and representation methods.&lt;/p&gt;&#xA;&lt;h2 id=&#34;start-with-domain-meaning&#34;&gt;Start with domain meaning&lt;/h2&gt;&#xA;&lt;p&gt;A price represented as a dictionary is easy to misuse:&lt;/p&gt;&#xA;&lt;div &#xA;    x-data=&#34;{&#xA;        code: $el.querySelector(&#39;code&#39;).innerText&#xA;    }&#34;&#xA;    class=&#34;relative my-4 rounded-lg group&#34;&#xA;&gt;&#xA;    &lt;button&#xA;        @click=&#34;navigator.clipboard.writeText(code); $el.innerText = &#39;Copied!&#39;; setTimeout(() =&gt; $el.innerText = &#39;Copy&#39;, 2000)&#34;&#xA;        class=&#34;absolute top-2 right-2 bg-neutral-700 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity&#34;&#xA;    &gt;&#xA;        Copy&#xA;    &lt;/button&gt;&#xA;    &#xA;    &lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;price &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; {&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;amount&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;1299&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;currency&amp;#34;&lt;/span&gt;: &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;USD&amp;#34;&lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;Any caller can omit a key or accidentally mix cents and dollars. A value object makes the contract explicit:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Python Protocols and Structural Subtyping for Flexible APIs</title>
      <link>https://nalar.dev/python-protocols-and-structural-subtyping/</link>
      <pubDate>Tue, 01 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/python-protocols-and-structural-subtyping/</guid>
      <description>&lt;p&gt;Python code often depends on behavior rather than a specific class hierarchy. A function may only need an object with a &lt;code&gt;send()&lt;/code&gt; method, a &lt;code&gt;read()&lt;/code&gt; method, or a pair of repository operations.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;typing.Protocol&lt;/code&gt; lets type checkers describe those behavioral requirements directly. A class satisfies a protocol by having compatible members; it does not need to inherit from the protocol.&lt;/p&gt;&#xA;&lt;p&gt;This is structural subtyping: &amp;ldquo;if it has the required shape, it can be used here.&amp;rdquo;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
