2 min read

Issue #30

iOS Code Review newsletter for Swift developers | Curated code improvement tips

Hi there,

I hope the summer is treating you well, and you're progressing toward your goal, whatever it is!

As promised in the last issue, here's me sharing behind-the-scenes on how I make the newsletter issues: https://youtu.be/CgTqqkzeeh8

Let's dive in 👇


On push notifications

Last week Airbnb accidentally sent a test push notification to real users. Sarun has a good point - it's not a good idea to use inappropriate words in text that could be seen by users. This applies to everything - not just push text, but also in code that shouldn't theoretically be executed in non-debug builds.

The sum effort

This simple formula Jane shared really put things in perspective for me.

Also it brought me to realise: if someone put effort into making the code more readable and well-structured, then it's less effort to read / work with later. If someone wrote "bad code" - perhaps spent less effort writing it - it takes extra effort to read later. Either way, the sum of total effort can be the same. No easy way out, the effort has to be spent by someone at some point, always.

Better equality test failures

If you've ever seen a test failure like this and hated it, Difference is a package that can help. It offers a diff function that returns a readable explanation of what exactly is different. The doc for the library includes examples of how to easily use this with XCTest, Quick, and Composable Architecture.

GitHub - krzysztofzablocki/Difference

Simple way to identify what is different between 2 instances of any type. Must have for TDD.

REST API

If you ever wondered what's the difference between just API and REST API, here's a short, digestible writeup about it:

On code duplication

The problem of duplication is more nuanced than it seems. Common advice such as "duplication is cheaper than the wrong abstraction" is often based on the simplified view of the problem, that it's just about code.  In this article @JasonSwett looks at what duplication actually is, why it’s such a surprisingly complicated problem, and what can be done to address it. Thanks @ctietze for sharing the post!

We could imagine that duplication could be defined as a piece of code that appears in two or more places. Indeed, this sounds like a very reasonable and accurate definition. But it’s actually wrong!
Duplication is when there’s a single behavior that’s specified in two or more places

Duplication - Code with Jason

In this post I’ll show what duplication is, why it’s such a surprisingly complicated problem, and what can be done to address it.

🤘

Alright, that’s it for today.

Did you enjoy this issue? Let me know by pressing the buttons below. If you enjoyed it, you can help grow the newsletter by spreading the word ☺️

Got feedback? Want to see more, or less of certain kinds of tips? I’d love to hear from you. Reply to this email or reach out on Twitter via @ios_code_review 🙌