If you aren’t careful, you can mutate constants!

If all you’re doing is using structs over classes, your code isn’t necessarily safe

If you’ve been doing Swift Development for any length of time, I’m sure you’ve heard that it’s good practice to use a struct over a class by default. While this is true in many cases, and for good reason, it’s very easy for a struct to be just as unsafe…


Decoupling code with protocols and delegation

A bunch of suitcases on display
Um, you’re only leaving for a few days, do you really need all that? (photo credit: arthur-edelmans, unsplash.com)

Imagine you’re going on vacation. You know exactly where you’re going, how long you’re staying, and the weather pattern is very reliable. You’re super prepared for what’s to come, and you know exactly what you’ll need when you get there. It wouldn’t make sense to pack everything you own and…


No architecture needs to have a massive view controller

Small, blurry background text with the words “very tiny” magnified
Tiny ViewControllers? Very tiny

So you’re sick of massive view controllers? Me too. Many architectures attempt to overcome this problem in a way that I view as extremely complex for the problem they’re trying to solve.

I favor simple architectures and simple solutions because they’re easy to understand, develop, and maintain. For this reason…


From verbose to concise

A hand touching a large digital display of some sort
Photo by Elia Pellegrini on Unsplash

Say you’re making a singleton or static class to represent data and/or logic that will never change. In many cases, you can convert this logic to an enum and save yourself a bunch of hassle. An enum has much of the functionality of a class, but doesn’t require an instance…


The single responsibility principle in action

Your ViewControllers don’t have to be so massive

In this tutorial, we’ll implement MVC in a way that you may not be familiar with. We’ll create a reusable UICollectionView that’s implemented by its parent UIView and delegates item selection events to a UIViewController. This makes for a very small view controller when compared to the default way we…


Is async/await ready for production?

A person sitting on the couch, waiting for a text

A lot of us have been waiting a long time for async/await syntax in Swift. First proposed in 2017, this API sets out to clean up the pyramid of doom that happens so often with async code. In the WWDC State of the Union, we were introduced to some amazing-looking…


Take your development to the next level, eliminate your assumptions with Unit Tests

Don’t you wish you had an automated way to test your code every time you make a change? Good news! You do!

If you’re anything like me, you make a lot of assumptions when you develop software. Also, if you’re anything like me, you probably didn’t realize it until recently, or maybe you still don’t realize it. …


Increase performance by avoiding retain-cycles

vertically scrolling numbers, dripping/leaking down the page
Ew, leaky code

In Swift, memory is handled for us pretty efficiently via ARC. Basically, reference objects (such as classes) hold a count for how many times they’re being referenced. When the count reaches 0, the item is marked for deallocation and removed from memory when the system needs the space.

If we…


A good API doesn’t break easily

A little blue character with a repair kit looking at a hole in a website or app
Keep those holes closed, so your users don’t experience interruptions!

Often when developing codebases, you probably want to model a situation with one of 2 possible outcomes. In Swift, this often means using optionals as the return type for a method. The idea is one of them will be nil, and the other will be non-nil.

What you may have…


The factory pattern keeps your code clean. Enums keep data flexible

Encapsulate your static initialization data — keep your call sites and objects clean

They’re all boxes, but they might have different labels. How do you handle such a case?

One Type, Different Property Values

Often times when creating a custom type, you’ll want to create many instances of that type with different initialization values. …

Kenny Dubroff

I’m a Full Stack iOS Developer with a passion for writing clean, reusable code.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store