4 min read

Issue #62

Hi there, welcome to the first issue of 2024!
I hope you had wonderful holidays, and are ready for the new year. Let's remember to have a balance between work, fun, and rest ๐Ÿง‘โ€๐Ÿ’ป๐ŸŒณ๐Ÿ›‹๏ธ

We passed 3000 subscribers over the holidays, a warm welcome to everyone who just joined ๐Ÿ‘‹ I'm grateful to y'all loyal subscribers for being along with the ride ๐ŸŽ‰

Let's dive into some learnings ๐Ÿคฟ

Setapp offers a collection of 240+ trustworthy, advanced apps under one simple subscription. You will find apps such as Ulysses, Paste, DevUtils, Asset Catalog Creator Pro, Craft, Structured, and many more.
Try Setapp for free

Naming unit tests

When a test fails, we want to understand what broke. When a name is descriptive, we can get the gist of what broke without reading the test code. It's especially useful when a test failure happens on CI. Jon describes a good formula for naming the tests:

Unit Test Naming: The 3 Most Important Parts | Quality Coding
Have you run tests, gotten a failure, and had to dig through test code to understand it? Use this unit test naming convention for faster feedback.

[UI]Image memory footprint

Memory usage โ‰  file size.
"Memory use is related to the dimensions of the image, not the file size." - Session 416, WWDC 2018

To reduce our app's memory footprint and reduce chances of the app being killed in the background, we can:

  • make sure there are no memory leaks (in UIKit, views deallocate). Use Debug Navigator (spraypaint icon in Xcode) and Leaks and Allocation instruments.
  • downsample images to view size before display (an image larger than its frame uses memory unnecessarily). See the article for how to do it.
  • when an image cache library is used, remember to set the memory cache limit.
Reducing Memory Footprint When Using UIImage - Swift Senpai
Learn how to use image downsampling to drastically reduce an app memory footprint when dealing with high definition UIImage.

Typestate pattern: next-level type safety

The concept of typestates describes the encoding of information about the current state of an object into the type of that object. I'm a big proponent of using the type system to apply domain constraints, so the compiler checks that logic for us.

In this article you can learn how generics and noncopyable types available from Swift 5.9 help take type safety to another level:

Typestate - the new Design Pattern in Swift 5.9 | Swiftology
In this article I will introduce you to Typestate pattern, popularised by Rust language, now available in Swift 5.9. You will see how the combination of generic constraints and Swiftโ€™s new memory ownership model allows you to write bulletproof code.

What game are you playing in life?

We are in the beginning of a new year, perfect time to reflect.
Imagine your career as a game. What game is that? What are the objectives? What level are you at, and what quest do you need to complete to advance to the next level? I'm curious to hear in replies what that is for you โ˜บ๏ธ

Complete And Total Gamification: Life as a Game
This article is inspired by one of my favourite scenes from Guy Ritchieโ€™s The Gentlemen and a great book called Games People Play, by Ericโ€ฆ

New video alert

I visited The Mayank Show to share my insights on becoming a lead developer. We talked about boosting your career, moving abroad, system design, mentoring, running a newsletter, conferences, and what's different between 2011 and now ๐Ÿ˜


โœŒ๏ธ
Alright, that's it for today! Let's spread the good code vibes โœจ๐Ÿง˜๐ŸŒˆโ˜€๏ธ
I'm curious if you found any of the tips particularly interesting - let me know by replying to this email!

* this issue contains an affiliate link to Setapp