<?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 Byron Mackay on Medium]]></title>
        <description><![CDATA[Stories by Byron Mackay on Medium]]></description>
        <link>https://medium.com/@byronmackay?source=rss-5602402229c8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*BAeXaTneDg34EJbp.</url>
            <title>Stories by Byron Mackay on Medium</title>
            <link>https://medium.com/@byronmackay?source=rss-5602402229c8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 12:48:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@byronmackay/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[The Value of Teaching Fundamentals Last]]></title>
            <link>https://byronmackay.medium.com/the-value-of-teaching-fundamentals-last-ab2f6218642d?source=rss-5602402229c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab2f6218642d</guid>
            <category><![CDATA[teaching]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[whole-task]]></category>
            <dc:creator><![CDATA[Byron Mackay]]></dc:creator>
            <pubDate>Tue, 16 Jan 2024 22:53:47 GMT</pubDate>
            <atom:updated>2024-01-16T22:53:47.302Z</atom:updated>
            <content:encoded><![CDATA[<h3>Teaching Fundamentals Last</h3><p>One aspect of teaching often overlooked is teaching something called “whole task.” The whole task provides a 30,000 ft view of performing a major task from start to finish that utilizes the skills the student will learn. This is a far cry from many intro-level courses that tend to start with fundamentals. Starting with the fundamentals seems logical, but it can be surprisingly detrimental. Why, you ask? Because students have to wait to understand where the concepts fit into the bigger picture. This waiting can kill motivation and momentum, and it’s why I’m so intrigued with the idea of teaching using big-picture ideas and leaving fundamentals off until the end.</p><p>Yes, you read that right: fundamentals move to the end of the curriculum.</p><p>Teaching fundamentals at the end sounds crazy, but let me prove that it’s not with two quick examples from my life: playing Little League baseball and learning math. Before stepping onto a baseball field or throwing my first ball, I had seen roughly 100 baseball games between my siblings’ little league games and professional baseball. By age 5, I had a solid and intrinsic idea of the game. I recall parts of the game didn’t make sense (i.e. tagging up on a pop fly). Still, by the time it was my turn to walk onto the field, I had a solid grasp of the game’s elements regardless of the fact that I had no fundamental skills (I could play our baseball video games pretty well, though).</p><p>Compare that to my experience learning math. By the time I was in the fifth grade, I had learned all the math I would ever use (addition, subtraction, multiplication, and division). I would go on to learn geometry, the quadratic equation, and some Calculus, but to this day, I could not tell you a use case for derivatives (or anything else passed my fifth-grade math class). By the time I finished high school and college, I had learned a great deal of math, but most of it was irrelevant because I couldn’t see how to use it in the world. A huge missed opportunity, and a consequence of teaching fundamentals without context.</p><p>Tell the student how something fits in their world, and that student will have all the motivation to learn it. Students must learn how things are applied for the fundamentals to sink in. That is why teaching the whole task and working backward is so critical to one’s learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab2f6218642d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Thoughts on communicating effectively through code]]></title>
            <link>https://byronmackay.medium.com/thoughts-on-communicating-effectively-through-code-38183a6cf6cf?source=rss-5602402229c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/38183a6cf6cf</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[judgement]]></category>
            <category><![CDATA[documentation]]></category>
            <dc:creator><![CDATA[Byron Mackay]]></dc:creator>
            <pubDate>Fri, 15 Jan 2021 17:02:01 GMT</pubDate>
            <atom:updated>2021-01-19T15:31:43.827Z</atom:updated>
            <content:encoded><![CDATA[<h3>Document your code. Use comments if necessary.</h3><p>As software engineers, we build relationships with other developers through code. Whether it’s looking at a new API or reviewing a co-worker’s code, we immediately form opinions of the code and the developer. So it’s very important that our code is readable and conveys what it’s trying to do.</p><p>Lately, I’ve been helping teach new developers. Getting code to run is challenging enough for many of them, but I feel strongly that they must learn clean coding principles as well. Otherwise, when they get out into the world, their reputation could be tarnished quickly for not doing some simple housekeeping. In light of this, I’ve come up with three principles that I feel any developer should take on, regardless of their level.</p><h3><strong>1. Use clear variable names</strong></h3><p>Variable names tell us what their contents are and what their contents do. If I have a list of users, then an appropriate name is “users”. If I have a boolean for if the user is authenticated, then “is_authenticated” would be appropriate. What you want to avoid are things like “u” and “auth”. Be descriptive.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df603b51f9e085b46493363a1d2d0af9/href">https://medium.com/media/df603b51f9e085b46493363a1d2d0af9/href</a></iframe><h3><strong>2. Break up your code with white space and functions</strong></h3><p>Just like no one likes reading a run-on sentence, no one likes code crammed into one line or even 100 consecutive lines. Instead, use a line break to denote which areas go together and when focus changes. Functions do a great job of this, especially when that function does one specific thing.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1077a23a0d24047c44bad579fb76339d/href">https://medium.com/media/1077a23a0d24047c44bad579fb76339d/href</a></iframe><h3><strong>3. Code should be the first source of documentation</strong></h3><p>To adapt an old adage, “Put lots of documentation in your code. Use comments when necessary.” Your code should be expressive enough that someone can read it without comments and understand it. Now, this must be applied with some consideration for your audience. If you’re writing code for new programmers, you’ll probably use more comments. In your company codebase, a comment would be useful if your code does something that looks out of place, but is actually essential to the work at hand. These comments, however, are last resorts. The code should explain what’s happening and if it can’t be done in code alone, use comments when necessary.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6882c0807108f165ca5409ac444c30de/href">https://medium.com/media/6882c0807108f165ca5409ac444c30de/href</a></iframe><p>What rules do you feel should be universally applied? What rules do you feel are “anti-patterns”?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38183a6cf6cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Show Pages on iOS]]></title>
            <link>https://levelup.gitconnected.com/dynamic-show-pages-on-ios-11d25c3311f2?source=rss-5602402229c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/11d25c3311f2</guid>
            <category><![CDATA[uitableview]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Byron Mackay]]></dc:creator>
            <pubDate>Thu, 08 Oct 2020 02:56:56 GMT</pubDate>
            <atom:updated>2020-10-08T04:26:04.766Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*QQ_R-SHKyRl0G-Q4P1AegA.png" /></figure><h3>One UITableViewController to Rule Them All</h3><p>Table views are the bread and butter of mobile development. Usually a table view will contain one cell view, but sometimes you want to do something like the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*U4wHDuVJCjhzdX4-CLe0iQ.jpeg" /></figure><p>This isn’t a random screen: I received this screen when I was just getting started in iOS development. I was told that there were roughly 15 different pieces of data (read: cells) that may or may not be displayed based on the data from the server. I admit that my solution at the time was poor (I used a scroll view for crying out loud), but I’ve since learned better.</p><p>A table view is the way to go, but how do you manage all the different cell types? In the view controller? Sounds like a mess! And any future updates involve a massive, convoluted file. To get around the bloated view controller, a friend of mine showed me a strategy using a presenter and enums, and it changed the way I approach table views all together.</p><h4>The Cell Object</h4><p>The main idea of this strategy is to create an array of Cell objects which abstracts the model into primitive data types. You’ll first need a Cell object that holds a portion of the data with some cell metadata. Cell will hold a title, value, and a CellType (which is an enum):</p><pre>struct Cell {<br>    var title: String<br>    var value: Any?<br>    var cellType: CellType<br>}</pre><pre>enum CellType {<br>    case text, toggle, image<br>}</pre><p>Notice that value is of type Any so that we can use any object and pass it to the cell (preferably primitives, but it can be anything if needs be). Now that we have the Cell object, we’ll build the array of Cells.</p><h4>The Presenter</h4><p>Call it a controller if you want, but this class’s job is to package the data in a way that the view can display it. The presenter will be given an object (in this case, a customer), and will package the data into an array of Cell objects we made above that the view controller can understand:</p><pre>class CustomerShowPresenter {<br>    var customer: Customer<br>    var cells: [Cell] = []</pre><pre>    init(customer: Customer) {<br>        self.customer = customer<br>    }</pre><pre>    func loadCells() {<br>        cells = []<br><br>        cells.append(Cell(title: &quot;Image&quot;, value: customer.image, cellType: .image))<br>        cells.append(Cell(title: &quot;Name&quot;, value: customer.name, cellType: .text))<br>        cells.append(Cell(title: &quot;Birthdate&quot;, value: customer.birthdate, cellType: .date))<br>    }<br>}</pre><p>The power of this strategy is that we can reuse it with any object because the array&#39;s contents are object agnostic. This is critical. Once the cells are loaded into the array, it’s time to make a reusable UITableViewController.</p><h4>Reusable UITableViewController</h4><p>Much like the cells array above, a reusable UITableViewController doesn’t care about the object that it’s representing, but rather the cell data that it is displaying. The presenter takes the concrete data object and dumbs the data down into abstract cell data that the view controller can display. Inside the UITableViewController, most of the calls get to be cut and dry so I won’t go over a lot of it. The most interesting part of this is the cellForRowAtIndexPath call, so let’s look at that:</p><pre>override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {<br>    //get the cell data from the presenter<br>    let cellData = presenter.cells[indexPath.row]</pre><pre>    //switch on the cell type to determine which cell you should show. Each cell can take a Cell object and configure itself.<br>    switch cellData.cellType {<br>    case .text:<br>        let cell = tableView.dequeueReusableCell(withIdentifier: &quot;text&quot;, for: indexPath) as! TextTableViewCell<br>        cell.configure(cellData)<br>        return cell<br>    case .date:<br>        let cell = tableView.dequeueReusableCell(withIdentifier: &quot;date&quot;, for: indexPath) as! DateTableViewCell<br>        cell.configure(cellData)<br>        return cell<br>    case .image:<br>        let cell = tableView.dequeueReusableCell(withIdentifier: &quot;image&quot;, for: indexPath) as! ImageTableViewCell<br>        cell.configure(cellData)<br>        return cell<br>}</pre><p>Do you see the Customer object anywhere? The view controller doesn’t need to know what the object is, but instead it cares what type of cell it should display at each index. Ultimately, the presenter could transform any object it into an array of Cell objects and the same ViewController could be used.</p><h4>CellPresenterProtocol</h4><p>With the view controller ready, we can make a new presenter and not use a new view controller. A presenter protocol will help us do this.</p><p>For the purposes of this example, the protocol has only two things: an array of Cells and the function loadCell().</p><pre>protocol CellPresenterProtocol {<br>    var cells: [Cell] { get }<br>    func loadCells()<br>}</pre><p>With the protocol ready, we can inject the presenter when we instantiate the reusable view controller.</p><pre>//Just showing how instantiating each page follows a very simple pattern<br>func showCustomerViewController(customer: Customer) {<br>    let showPresenter = CustomerShowPresenter(customer: customer)<br>    pushShowTableViewController(presenter: showPresenter)<br>}</pre><pre>func showOrderViewController(order: Order) {<br>    let showPresenter = OrderShowPresenter(order: order)<br>    pushShowTableViewController(presenter: showPresenter)<br>}</pre><pre>func showProductViewController(product: Product) {<br>    let showPresenter = ProductShowPresenter(product: Product)<br>    pushShowTableViewController(presenter: showPresenter)<br>}</pre><pre>private func pushShowTableViewController(presenter: CellPresenterProtocol) {<br>    let showViewController = ShowTableViewController(presenter: presenter)<br>    navigationController?.pushViewController(showViewController, animated: true)<br>}</pre><h4>Conclusion</h4><p>Passing only an array of cell data to your view controller reduces the tableview delegate and data source complexity, especially when cells are of all different types. Setting up tables to handle cell data instead of data in this way has many advantages:</p><ol><li>Your view logic can be reused. Since the view controller doesn’t know about the object it’s showing but only about an abstract “Cell” object, the view controller can be easily reused, meaning you have a lot less code to build and manage.</li><li>What the cells contain and how they’re ordered is more easily managed. If you want to change where a value is, moving it in the array is far easier than trying to manage it in the view controller.</li><li>Presenters for show pages follow the same format, making them much more familiar and readable to the other devs on your team (or you in three months when you add a new feature to the code).</li></ol><p>I hope this helps you build better and reusable table view logic.</p><p><a href="https://github.com/bqmackay/ReusableUITableViewController">Here’s a link to the demo project.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11d25c3311f2" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/dynamic-show-pages-on-ios-11d25c3311f2">Dynamic Show Pages on iOS</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>