clean-architecture
Again, we simply need to move as much logic as possible out of the view body and put it into variables and functions we can see from outside the view.
Because, and to paraphrase a military axiom: If we can see it, we can test it.
Because, and to paraphrase a military axiom: If we can see it, we can test it.
Michael Long • SwiftUI: Choosing an Application Architecture
Over the years we developed a few guidelines to help us out. Ideas like the single responsibility principle, the open-closed principle, the dependency inversion principle, and separation of concerns .
Michael Long • SwiftUI: Choosing an Application Architecture
The Many Flavors of Unidirectional Architectures in Swift
medium.comTests should check what Store exposes publicly not how it’s implemented under the hood
Concrete example in SwiftUI terms:
Input: onAppear.
Expected observable behavior:
State transitions: idle → loading → loaded([1,2,3]) or error.
Output: numbersDownloaded (optional).
Whether you implement the fetch as a .task effect, a command array interpreted by a handler, or a class conforming to Effect, your test should only verify that those state transitions and outputs occur in order.
Keep in mind that dismissal is largely imperative and fragile. Like manually popping views off the navigation path, it depends on an assumption of how the app is constructed and what views have been pushed and presented.
That’s not much of a problem if you’re coming at it from the application root side during a deep link. But it can be one if you’re... See more
That’s not much of a problem if you’re coming at it from the application root side during a deep link. But it can be one if you’re... See more
SwiftUI Navigation With Dismissible
a dismissible view is a presented view that Navigator knows how to dismiss .
SwiftUI Navigation With Dismissible
Each enumerated value is a view. Evaluate the enumeration and the value’s body switch returns the view we need.
SwiftUI: Eliminating Navigation Registration
What’s the state of the art for dependency injection libraries? All the ones I looked at use the experimental decorators, and I’m not sure how well that’s going to play with the newer ecmascript decorators coming soon.
Is there another option or should I just use tsyringe?
reddit.comDiscussion on pragmatic dependency injection
Conforming to these simple rules is not hard, and will save you a lot of headaches going forward. By separating the software into layers, and conforming to The Dependency Rule , you will create a system that is intrinsically testable, with all the benefits that implies.
Robert C. Martin (Uncle Bob) • Clean Coder Blog
Dependency rule: as you you go into circle, abstraction level increases and nothing in inner circle knows about outer circle
For a good code design it's very important to use proper abstractions because they make our code loosely coupled . That means that different componenets of our code can be replaced with alternative implementations without affecting other components. When our code is loosely coupled it becomes easier to test, easier to extend, easier to reuse,... See more