EXPERIMENTS

#076 Dub to the Core (Data)
    dupdate
by Anupam, 04/26/23

Context

This week’s writeup is pretty brief! Experiment still in progress :)

Overview

Besides a few small tweaks & bug fixes, we’re still pushing forward data persistence this week (using CoreData). This is the last major feature step before app launch - and it’s just starting to come together.

This week was mostly a collab between Cam and I on mapping out the app’s new data structure and kicking forward the implementation.

We also have embarked on rewriting the app with MVVM (Model-View-ViewModel) in mind - which should afford us some more modularity down the road.

Process

Most of this week has been thinking and implementing that thinking in code (so not a ton of new info to share).

A nifty little Swift trick I’ve picked up this week though is generics for templated functions. They’re really cool!

Now, I’ve been able to write fairly generic functions to do complex things - like, a function that takes in an optional and its origin, tries to unwrap it, and logs a descriptive error if it fails.

static func unwrapOptionalAndCrash<T, U>(optnl: T?, from: U) -> T {
	guard let unwrapped = optnl else {
		DataError.cantUnwrap.logError(object: optnl, from: from)
			fatalError(DataError.cantUnwrap.getErrorInfo(object: optnl, from: from))

        }
        return unwrapped
    }

Next Steps

Keep implementing this new structure! Overcoming this final hurdle is all we need to launch, and puts us in a really good position for adding features down the line :)