Excellent article!

I would just add that you can improve the separation of concerns, (without over complicating it):

1. The view model should only know about view concerns, not business/model concerns. For example, use variables like `title`, `detail`, rather than `orderItem`, `itemDescription` and `itemTotal`.

2. You can make an extension of your view model to map particular/different model/business logic into your view model, such as with a convenience init, such as `title: orderItem.description`.

3. The view and view model can then be used to represent numerous business/models. For example, the `OrderDetailsRowView`'s `detail` might be used for an `orderItem.itemDescription` or an `iceCream.flavor.name`.

--

iOS developer and architect for BareFeetWare. Builds apps for enterprise and startups. Runs workshops on building apps like Lego.

Love podcasts or audiobooks? Learn on the go with our new app.

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
Tom Brodhurst-Hill

Tom Brodhurst-Hill

iOS developer and architect for BareFeetWare. Builds apps for enterprise and startups. Runs workshops on building apps like Lego.