Stop writing rubbish!

Image for post
Image for post
Photo by The New York Public Library on Unsplash

Difficulty: Beginner | Easy | Normal | Challenging

Here is a video version of this article

Not great

Here I can loop through the input Strings, adding the comma to each element in turn.

But there is a wrinkle in this! The last element would have a comma appended to the end! This is then removed with a quick outputString.removeLast().

The potential function is shown here:

Better

We can use a map combined with String interpolation to join the elements with a comma.

Here is the end result:

Testing

This wouldn’t be a great article without some testing! The following works only in a playground (which is why we hit defaultTestSuite) and more testing information is avaliable in my TDD article, but in any case here is the…


Inject those dependencies!

Image for post
Image for post
Photo by Nong Vang on Unsplash

Terminology:

Dependency Injection: A technique that allows objects to receive other objects on which it depends
MVVM: An architecture pattern consisiting of Model, View and View-Model Storyboard: A visual representation of the User Interface of an Application

Useful prerequisites

The Video Alternative

The example

Sorry, this is awful. I’ve created two simple screens, neither of which display anything for the user other than a button to go onto the next screen. The first screen makes a network call but prints out the result to the console.

Simple stuff, right?

MVVM

I’m going to implement MVVM as follows:

Image for post
Image for post

this means that we have three seperate sections — the View, View Model and Model. …


We don’t want to preload every ViewModel!

Image for post
Image for post

Photo by Abel Y Costa

Difficulty: Beginner | Easy | Normal | Challenging
This article has been developed using Xcode 12, and Swift 5.3

Prerequisites:

* You will be expected to make a Single View Swift Application
* This code is built on my network manager, which you can download and use for free
* This involves subscripts that I’m covered in Create your own subscript
* This code uses Singletons

Terminology

Cache: a collection of items of the same type stored

The motivation

Alamofire has a cache. …

About

Steven Curtis

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