<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Domain-Modelling on Pauls Blog</title><link>https://prule.github.io/pauls-blog/tags/domain-modelling/</link><description>Recent content in Domain-Modelling on Pauls Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 22 May 2026 12:00:00 +1000</lastBuildDate><atom:link href="https://prule.github.io/pauls-blog/tags/domain-modelling/index.xml" rel="self" type="application/rss+xml"/><item><title>Kotlin Value Objects Beat Primitives</title><link>https://prule.github.io/pauls-blog/post/coding/2026/kotlin-value-objects/</link><pubDate>Fri, 22 May 2026 12:00:00 +1000</pubDate><guid>https://prule.github.io/pauls-blog/post/coding/2026/kotlin-value-objects/</guid><description>&lt;p&gt;Use value objects. Primitives leak implementation details, enable invalid states, and produce meaningless function signatures. A &lt;code&gt;UserId&lt;/code&gt; is not an &lt;code&gt;Int&lt;/code&gt;. A &lt;code&gt;Money&lt;/code&gt; is not a &lt;code&gt;Double&lt;/code&gt;. The type system is your first line of defence — use it.&lt;/p&gt;
&lt;h2 id="the-problem-with-primitives"&gt;The Problem With Primitives&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-kotlin" data-lang="kotlin"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;from&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Double&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="p"&gt;.&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;p&gt;Nothing stops a caller passing the arguments in the wrong order. Nothing prevents a negative amount. Nothing distinguishes a user ID from an account ID. The compiler is silent. The bug ships.&lt;/p&gt;</description></item></channel></rss>