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. For example, if you’re modeling a Vehicle, you may want different vehicles with a different number of wheels, different colors, different body styles, etc…

To achieve this, we often make our initializers flexible by being able to pass in whatever value we want for each property we’re initializing. While there’s nothing wrong with this solution, it can lead to a lot of boilerplate code at call sites…

Understanding Extensions and Closures

A clipboard with arbitrary text
A clipboard with arbitrary text
Lists, lists, everywhere a list

The goal

Create a method in a linked list that we can use to iterate over it and pass in code to do something with each position.

Linked Lists — A brief introduction

According to

A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers…

In other words, a Linked List is like an array, but it’s stored using random access (pointers) rather than solid blocks of memory (contiguous memory locations). …

The case of the inseparable duo

What you’ll learn about in this article:

  • Memory Management
  • Automatic Reference Counting (ARC)
  • Retain Cycles
  • What strong vs. weak vs. unowned mean, and when to use them
A man holding an empty bird cage. Like an app holding a reference it doesn’t need to
A man holding an empty bird cage. Like an app holding a reference it doesn’t need to
Retain cycles cause your app to hold onto things it should let go of

Memory Management Introduced

In Software Development, memory management is a crucial aspect of an efficient, maintainable application. When we’re talking about Mobile Development, memory management is definitely crucial because our devices have fewer resources, and throttle those resources more often than their live-in counterparts. In the iOS world, poor memory management will cause the OS to kill your app if your app’s memory space reaches an unknown limit.

Memory is what we mostly use to temporarily store data in our app. If you…

Enums — encapsulating code ✅ modifying data ✅ doing it all cleanly ✅

Map of Continental United States
Map of Continental United States
The map is missing a couple… but we won’t 😉

Our use-case

We’re building a shopping app for US customers. The requirements are such that we must use States and abbreviations in several places in our app, and it’s important that our spelling remains consistent. Sometimes we’ll need a single state’s name, sometimes we’ll need the state’s abbreviation — other times we’ll need both. Sometimes we’ll need an array of all of their names, other times we’ll need an array of all of their abbreviations. Finally, there are times where we’ll need both in an array so we can easily access either one in a list.

Let’s start with the basics

Most times I see enums used…

How to limit a variable in Swift

Over the years, I’ve had a few instances where I needed to limit the potential of a variable. For instance, maybe I have a shopping app and I need to limit the maximum price of any given item. You may be surprised to learn that there’s no built-in way to tackle this in the Swift Standard Library. There are many solutions, but most come with glaring caveats.

Let’s start with a use-case

I have a UICollectionView. In this collectionView, I only want to display a maximum of 2 cells. This collection view’s count is based on an array that could have thousands of entries. …

How to refactor without hurting yourself

… and passing a closure

And what the heck does `layer is a part of cycle in its layer` mean???

Image courtesy

“layer is a part of cycle in its layer”

Xcode barked at me as my app crashed. It was right after I created my first test view using a new Framework that my friend, Aaron Cleveland developed for programmatic Autolayout. I wanted to blame the way he was linking constraints in one of the convenience methods. But that was all standard best practice-y stuff there.

I looked over the convenience initializers I had added to his framework for UIStackView numerous times. Everything seemed in order there. “Hmm, the problem must be somewhere else in his framework,” I thought.

I headed over to StackOverflow and looked over this thread for…

Why you should use enums instead

Stop letting magic strings make you look foolish

Using strings as a way of controlling the flow of an app, whether it be some condition you’re checking, an identifier, or a number of other things just isn’t a great experience. Especially as your app grows in size.

At one point or another, I know we’ve all spent time thinking, “what was the name of that identifier again?” … then you go back to look, and by the time you find it and copy it, you forgot what you needed it for in the first place. …

Demystifying the “R-Word” using Python

In my many years of working with different programming languages, I’ve come across the “R-Word” (recursive!) more times than I cared to count. Until it clicked for me as to what recursive functions were doing — I always ran in the opposite direction!

Recursive? Uhhh... what?

Recursive: “relating to or involving a program or routine of which a part requires the application of the whole, so that its explicit interpretation requires in general many successive executions.”

Right, ok… Uhhh… what?

Don’t worry, I didn’t understand that either. The easiest-to-understand way I’ve heard recursive functions explained is:

“A recursive function is…

My Development Process When I’m Stuck

I’ve been making apps for years. Mostly apps for friends and personal use, some with teams of developers, and I’ve worked on plenty of other people’s codebases. One thing is a constant in every one of these experiences — problems.

I sort of developed my own problem-solving framework over the years, and it was hit and miss. I was recently introduced to UPER through Lambda School and it’s changed the game entirely for me.

If you’re like I was, when faced with a problem, you probably do some form of restating the problem in a way that you can understand…

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