App architecture basics in SwiftUI Part 4: Services
Cocoa with Love
by
3y ago
This article is about adding a separated Services-layer to an app. A Services-layer is, in my opinion, the single best app architectural addition you can make, after the basic Model-View separation already implicit in SwiftUI. Where Model-View separation decouples the Model from the front-end, a Services-layer completes Model separation by separating the Model at the back-end and is one of the few app architectural changes you can point at and say: this change unlocks these capabilities. I’ll be changing just 9 lines from the 127 line CwlFeedReader app from the previous article (plus a few lin ..read more
Visit website
App architecture basics in SwiftUI Part 3: Module-separated layers
Cocoa with Love
by
3y ago
In the previous article, I looked at how SwiftUI’s data-driven changes force a basic separation between Model and View. The separation is limited in scope, requiring only that there exist a state value or observable object that drives view updates. If a cleaner separation between Model and View is desired, then slicing an app into modules (Swift’s name for discrete libraries) is the best technical step you can make. Separating architectural layers (e.g. Model, View, and optionally others) into their own modules lets you establish rules about how to connect your layers, which types and properti ..read more
Visit website
App architecture basics in SwiftUI, Part 2: SwiftUI's natural pattern
Cocoa with Love
by
3y ago
In the previous article, I wrote a simple SwiftUI app. During the writing, I deliberately kept the code simple – writing code only when needed to satisfy user-facing goals. I want to take a closer look at the application architecture that naturally emerges in SwiftUI when following this kind of functionally minimalist approach. Perform a web search for “SwiftUI pattern” and you’ll find numerous discussions of SwiftUI that wonder if its use of model-bindings make it a form of Model-View-ViewModel (MVVM) or if its use of immutable views and view-state make it redux or Elm-like. While SwiftUI doe ..read more
Visit website
App architecture basics in SwiftUI, Part 1: Coding through iteration and integration
Cocoa with Love
by
3y ago
In this series of articles, I’ll look at fundamental app architectural concepts and how they apply to an app written in SwiftUI. To begin the series, I want to start with something small: a JSON feed reader app in SwiftUI. I want to focus on the order of the steps, not the code itself and answer a common question: which should you write first, View-code or Model-code? The short answer is “both” (or “neither”) but properly answering the question offers a segue into a more important question: how can I make reliable progress as a programmer when I’m uncertain about what I’m doing or the blocks o ..read more
Visit website
22 short tests of combine – Part 3: Asynchrony
Cocoa with Love
by
4y ago
I wrote some experiments around Combine, Apple’s reactive programming framework, to gain insight into how Combine handles edge cases that have caused problems for me in other reactive programming frameworks. Looking at everything in one article got much too long so I broke it into three parts: re-implementing the core protocols of Combine a trio of topics: shared computation, shared reference lifetimes and sharing subscribers asynchrony, threading and performance This final part will look at asynchronous delivery scenarios. What happens in Combine when the next value arrives while the previo ..read more
Visit website
22 short tests of combine – Part 2: Sharing
Cocoa with Love
by
5y ago
I wrote some experiments around Combine, Apple’s reactive programming framerwork, to gain insight into how Combine handles edge cases that have caused problems for me in other reactive programming frameworks. How do subscriptions work? How do I cache computations? When are publishers and subscribers released? Under what circumstances is Combine thread-safe? Is re-entrancy possible? Does Combine guarantee delivery-order? How does Combine’s performance compare to pre-existing reactive frameworks? Answering all those questions in one article got much too long so this is a three part series. The ..read more
Visit website
22 short tests of Combine – Part 1: Protocols
Cocoa with Love
by
5y ago
I wrote some experiments around Combine, Apple’s reactive programming framerwork, to gain insight into how Combine handles edge cases that have caused problems for me in other reactive programming frameworks. How do subscriptions work? How do I cache computations? When are publishers and subscribers released? Under what circumstances is Combine thread-safe? Is re-entrancy possible? Does Combine guarantee delivery-order? How does Combine’s performance compare to pre-existing reactive frameworks? Answering all those questions in one article got much too long so this article will be the first th ..read more
Visit website
Cocoa with Love
Cocoa with Love
by
5y ago
Copyright Matt Gallagher, 2019. All rights reserved. Code samples may be use in accordance with the ISC-style license at https://www.cocoawithlove.com/about.html ..read more
Visit website
Tags
Cocoa with Love
by
5y ago
Copyright Matt Gallagher, 2019. All rights reserved. Code samples may be use in accordance with the ISC-style license at https://www.cocoawithlove.com/about.html ..read more
Visit website
Combine
Cocoa with Love
by
5y ago
Copyright Matt Gallagher, 2019. All rights reserved. Code samples may be use in accordance with the ISC-style license at https://www.cocoawithlove.com/about.html ..read more
Visit website

Follow Cocoa with Love on FeedSpot

Continue with Google
Continue with Apple
OR