<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Conor Brady on Medium]]></title>
        <description><![CDATA[Stories by Conor Brady on Medium]]></description>
        <link>https://medium.com/@cjbrady?source=rss-f17edb5eef4f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*r6Ibcc-9BKqa61dF5Cll5w.png</url>
            <title>Stories by Conor Brady on Medium</title>
            <link>https://medium.com/@cjbrady?source=rss-f17edb5eef4f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 08:56:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cjbrady/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Stylish UI Extensions (UIKit-CSS)]]></title>
            <link>https://medium.com/@cjbrady/stylish-uikit-extensions-uikit-css-4b026eb4cc6c?source=rss-f17edb5eef4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b026eb4cc6c</guid>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift-extensions]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Conor Brady]]></dc:creator>
            <pubDate>Wed, 26 Apr 2017 14:26:45 GMT</pubDate>
            <atom:updated>2017-04-26T16:41:46.746Z</atom:updated>
            <content:encoded><![CDATA[<p>This post carries on from <a href="https://medium.com/@cjbrady/the-mutate-operator-9f3ef3bcd90e">the mutate operator</a>. Which, among other things, laid out a way of applying mutation blocks to UIKit classes. We made use of this in our codebase, but soon started to realise we had repeated mutation blocks all over the place.</p><p>This was our new world:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a458afc6adfafb8eca2acfc08bcd5d6/href">https://medium.com/media/7a458afc6adfafb8eca2acfc08bcd5d6/href</a></iframe><p>We need to do better, what about:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b7d98545a02c617c3b34ad01970ae17/href">https://medium.com/media/0b7d98545a02c617c3b34ad01970ae17/href</a></iframe><p><a href="https://medium.com/@cjbrady/post-storyboards-87f783817e44"><em>Don’t you use storyboards and Interface builder?</em></a></p><p>Let’s extend UIFont.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b17b9f5783798d6d5ae4d61fe9e33db2/href">https://medium.com/media/b17b9f5783798d6d5ae4d61fe9e33db2/href</a></iframe><p>This gives us our font library. Back to our original example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbcdf82c7948e573b816195b52c26530/href">https://medium.com/media/dbcdf82c7948e573b816195b52c26530/href</a></iframe><p>Much better, but we still have repeated code. Let’s extend UILabel.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c242f3047bd4820dcae67306af32eca/href">https://medium.com/media/4c242f3047bd4820dcae67306af32eca/href</a></iframe><p>(With some bonus line wrapping functionality)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b7d98545a02c617c3b34ad01970ae17/href">https://medium.com/media/0b7d98545a02c617c3b34ad01970ae17/href</a></iframe><p>We’re left with two identical lines. This seems like we have more to do, but this is the nature of style-extensions.</p><p><strong><em>We must create an interface that balances:</em></strong></p><ul><li>A small API</li><li>Concise expressivity</li><li>Flexibility of interface</li></ul><p>This was our balancing point. Labels can vary so much outside of our four fonts and colour palette.</p><p>Adopting these to another codebase will mean different things, it could be dependant the designers involvement, where better light could be shed on the degrees of freedom of labels, headers etc.</p><h4>War of the buttons</h4><p>Buttons are another story, they don’t change too much.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd381800919e072420137126776520d1/href">https://medium.com/media/bd381800919e072420137126776520d1/href</a></iframe><p>For the sake of completeness this is a basically all the style-extensions for buttons. We generally only need stylePrimary(fontSize:_). This gives us a single point of reference so the engineer only needs to call UIButton().stylePrimary(fontSize: 14). The only thing they need to worry about is if they got the font size correct.</p><h4>What about everything else?</h4><p>There’s plenty more, this outlines the concept. It’s about raising awareness of a syntactical possibility and seeing where it goes rather than providing a styling library. So let us know what you think.</p><p>Any or all of this sound interesting? <a href="https://www.hubspot.com/jobs/departments/product-and-engineering">Join the HubSpot iOS team</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b026eb4cc6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Tasty UITableView Extension]]></title>
            <link>https://medium.com/@cjbrady/a-tasty-uitableview-extension-203fceed0250?source=rss-f17edb5eef4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/203fceed0250</guid>
            <category><![CDATA[generic-programming]]></category>
            <category><![CDATA[uitableview]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Conor Brady]]></dc:creator>
            <pubDate>Wed, 26 Apr 2017 13:08:31 GMT</pubDate>
            <atom:updated>2017-04-27T12:35:23.946Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d36ec7690041d9fa0871fddae5e0ad7c/href">https://medium.com/media/d36ec7690041d9fa0871fddae5e0ad7c/href</a></iframe><p>This extension is pretty nice, I thought it deserved a post. Here’s a snippet of it in use:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40565a45df8768ec8a4b6dc3bf0f1946/href">https://medium.com/media/40565a45df8768ec8a4b6dc3bf0f1946/href</a></iframe><p>It’s just tidy, it removes all the cell identifier stuff as we rarely need two identifiers for the same type of cell. If you do, you can still use the old version.</p><p>Also check out <a href="https://medium.com/@cjbrady/the-mutate-operator-9f3ef3bcd90e">this post</a> if you are curious what &lt;== is.</p><p>Any or all of this sound interesting? <a href="https://www.hubspot.com/jobs/departments/product-and-engineering">Join the HubSpot iOS team</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=203fceed0250" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Some operators improve code clarity]]></title>
            <link>https://medium.com/@cjbrady/the-mutate-operator-9f3ef3bcd90e?source=rss-f17edb5eef4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f3ef3bcd90e</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[interface-builder]]></category>
            <dc:creator><![CDATA[Conor Brady]]></dc:creator>
            <pubDate>Wed, 26 Apr 2017 12:49:17 GMT</pubDate>
            <atom:updated>2017-04-30T08:36:41.841Z</atom:updated>
            <content:encoded><![CDATA[<p>This is an infix, Swift operator; improving code expressivity and clarity. It gives a syntactic abstraction of something constantly done with mutable frameworks such as UIKit. We use it heavily on the HubSpot iOS team, becoming an indispensable tool in writing clear, maintainable code such as:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5a3c0e35ec2954013548883f9dfe53a/href">https://medium.com/media/c5a3c0e35ec2954013548883f9dfe53a/href</a></iframe><p>Here’s the implementation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c364f23c5fbcf0a477589c8d2cf44f06/href">https://medium.com/media/c364f23c5fbcf0a477589c8d2cf44f06/href</a></iframe><p>Below, I’ll list examples of its use; with hopeful evidence of of its merit.</p><h4>What?</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ede406141557877d001f65a7d4869dce/href">https://medium.com/media/ede406141557877d001f65a7d4869dce/href</a></iframe><p>We initialise Foo, but it’s not <em>really</em> initialised since we immediately want to assign bar. For some reason, Foo doesn’t accept bar in the constructor, so we end up with a create-assign pattern.</p><p>With &lt;== , we arrive at a better expression of our intent and we avoid assigning invalid states of foo.</p><h4>But, what about the real world?</h4><p>A pretty typical UIKit interaction:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33a873385c78773291dd9bcb3fb22158/href">https://medium.com/media/33a873385c78773291dd9bcb3fb22158/href</a></iframe><p>After we apply &lt;==:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ecdbce26e2c25764c3b6478bda585a9/href">https://medium.com/media/0ecdbce26e2c25764c3b6478bda585a9/href</a></iframe><p>This creates a single assignment and clear initialisation block. The blocks encourage the code to be grouped logically, with a strong syntactic contract.</p><p>If we mutated these objects outside their blocks, it would stand out. So we get reassurances that we have the full picture of any objects configuration and mutations at a glance. Even the layer configuration for the button’s drop shadow falls into place nicely.</p><h4>But wait, theres more</h4><p>Since we have customisable single assignment, we can apply it at the class level:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5a3c0e35ec2954013548883f9dfe53a/href">https://medium.com/media/c5a3c0e35ec2954013548883f9dfe53a/href</a></iframe><p>This constrains the creation to constant, class level information; factoring out anything that depends on parameters to the init call.</p><p>It also removes order dependency, so any order dependant mutations can be performed in the initialiser itself, reducing the noise surrounding interdependent, order specific instructions.</p><p>It all feels much more declarative. Like UI code should feel.</p><h4>I need more convincing…</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31c84355bdf39929d183169363e25fa9/href">https://medium.com/media/31c84355bdf39929d183169363e25fa9/href</a></iframe><p>At line 2, we don’t need v1 and v2 but we’re just using them as temporary variables so we can assign them titles, before passing them as arguments to the UITabBarController constructor. This is mostly how this pattern plays out in the wild.</p><p>Line 11 feels a lot better. We avoid polluting the symbol table with variables that are unnecessary; with the scope of use of the view controllers clearly indicated by the context of their creation and use.</p><p>This is more readable, as everything appears in context to it creation, modification and purpose. Rather than splitting that across three lines.</p><h4>I’m sold</h4><p>Try it out, it’s only 7 lines. It’s made our code much more easy to read and maintain. You’ll be glad of it.</p><p>Next thing, you can start making <a href="https://medium.com/@cjbrady/stylish-uikit-extensions-uikit-css-4b026eb4cc6c">style-extensions</a>.</p><p>Any or all of this sound interesting? <a href="https://www.hubspot.com/jobs/departments/product-and-engineering">Join the HubSpot iOS team</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f3ef3bcd90e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>