<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Building Software]]></title><description><![CDATA[It's hard.]]></description><link>http://blog.sdmadden.com/</link><image><url>http://blog.sdmadden.com/favicon.png</url><title>Building Software</title><link>http://blog.sdmadden.com/</link></image><generator>Ghost 2.14</generator><lastBuildDate>Thu, 14 May 2026 11:44:40 GMT</lastBuildDate><atom:link href="http://blog.sdmadden.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Lateinit vs Nullable for database fields with Kotlin and DynamoDB Mapper]]></title><description><![CDATA[<p>This is a pattern I've run into a few time while working with Kotlin.</p>
<p>I have a DynamoDB tables with some required fields, and some that get filled out later on in the user workflow. In my case, I register the user which saves details in DDB, and then I</p>]]></description><link>http://blog.sdmadden.com/lateinit-vs-nullable-for-database-fields/</link><guid isPermaLink="false">5978eecb1657010d8a71420b</guid><category><![CDATA[Kotlin]]></category><dc:creator><![CDATA[Sean]]></dc:creator><pubDate>Wed, 26 Jul 2017 20:04:13 GMT</pubDate><content:encoded><![CDATA[<p>This is a pattern I've run into a few time while working with Kotlin.</p>
<p>I have a DynamoDB tables with some required fields, and some that get filled out later on in the user workflow. In my case, I register the user which saves details in DDB, and then I let the user pick a phone number to buy through twilio, storing the choice in DynamoDB.</p>
<h2 id="thelateinitvar">The lateinit var</h2>
<p>There are two different ways forward that I can see. None of them let me use an immutable reference, so if you can think of a way to do it that way I'd love to hear about it.</p>
<pre><code class="language-kotlin">lateinit @DynamoDBAttribute(attributeName = &quot;phone&quot;) var phone: String
</code></pre>
<p>This means that the variable will be <a href="https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties">late initialized</a> and throw an <code>UninitializedPropertyAccessException</code> if it is accessed before it has been initialized.</p>
<p>The other option is to use</p>
<pre><code class="language-kotlin">@DynamoDBAttribute(attributeName = &quot;phone&quot;) var phone: String? = null
</code></pre>
<p>Note: lateinit does not work on Nullable variables - and with good reason. If null is a valid state then it can be initalized to null.</p>
<h2 id="thesolution">The solution</h2>
<p>I decided to use a nullable string variable for this purpose. There were a few things that helped me decide:</p>
<ol>
<li>I didn't want to use exceptions for flow control. I could try to read the phone number property and then catch the <code>UninitializedPropertyAccessException</code> and redirect the user to choose their phone number, but that is using exceptions as flow control.</li>
<li>Sticking with a nullable variable allows me to do <code>if (phone.isNullOrBlank())</code> - which allows me to redirect the user if they need to choose a phone number.</li>
</ol>
<h2 id="conclusion">Conclusion</h2>
<p>In order to avoid using exceptions for flow control, I opted for a nullable variable. Null is a valid state for some properties, and doesn't need to be avoided in Kotlin if you can't help using it.</p>
]]></content:encoded></item><item><title><![CDATA[Managing Secrets with Gitlab CI]]></title><description><![CDATA[<p>Because the advice &quot;don't check your secrets into source control and then push them to a public repository&quot; advice exists far more than any <a href="https://github.com/awslabs/git-secrets">practical solutions to the problem</a>, here's how I use gitlab CI to manage a few secrets for my Discord bot:</p>
<ol>
<li>Discord Bot Token (used</li></ol>]]></description><link>http://blog.sdmadden.com/managing-secrets-with-gitlab-ci/</link><guid isPermaLink="false">595b2baa7d009c301398da18</guid><category><![CDATA[Gitlab]]></category><dc:creator><![CDATA[Sean]]></dc:creator><pubDate>Tue, 04 Jul 2017 06:01:57 GMT</pubDate><content:encoded><![CDATA[<p>Because the advice &quot;don't check your secrets into source control and then push them to a public repository&quot; advice exists far more than any <a href="https://github.com/awslabs/git-secrets">practical solutions to the problem</a>, here's how I use gitlab CI to manage a few secrets for my Discord bot:</p>
<ol>
<li>Discord Bot Token (used to authenticate my bot)</li>
<li>SSH Keys needed for deployment</li>
</ol>
<h2 id="whydoineedthis">Why do I need this?</h2>
<p>Your secret keys and tokens should be kept secure. Anyone that discovers your discord bot token can create a bot that logs in and acts as your bot. Hard coding keys and tokens into a publically available projects means that anyone can pretend to be you and cause trouble.</p>
<p>example: you can see my OLD discord token in old commits. I've since revoked that token and updated it.</p>
<h2 id="gitlabsecretvariables">Gitlab Secret Variables</h2>
<p><a href="https://gitlab.com/help/ci/variables/README#secret-variables">Git lab CI</a> has built in support for two different kinds of secrets:</p>
<ul>
<li>
<p>Secret variables</p>
</li>
<li>
<p>Protected secret variables</p>
<p>The difference between the two, is that Protected secret variables will only be passed to <a href="https://docs.gitlab.com/ce/user/project/protected_branches.html">protected branches</a> or <a href="https://docs.gitlab.com/ce/user/project/protected_tags.html">protected tags</a></p>
</li>
</ul>
]]></content:encoded></item></channel></rss>