Clean Architecture using SwiftUI + Combine

I've just put together a base code for clean architecture using SwiftUI + Combine. I'd really appreciate it if anyone could take a look and give some feedback. Thanks!

It seems to be following general bias when trying to put such ideas as clean architecture into a set of predefined blocks. The key idea with it is not to be a set of concrete types and paired interfaces, but a guidelines on how to accomplish:

  • Separated domain logic.
  • Isolated UI.
  • Independent db/networking/etc.

It is not about introducing many protocols for unclear needs, which is often is one of the main arguments agains clean architecture.

In case of this example, I see issues:

  • First of all it is not clear what apps do from its structure, to get to the point where you can understand what parts are there you have to go through several layers of nested directories.
  • Too, extremely too many protocols of unknown purpose. It is completely unclear why would you need a protocol with each use case for example? (yep, I know it's for testing and "better separation", but that things should be introduced on demand, when it is beneficial, not always).
  • Injections are hiding data flow and dependencies in the system, making it hard to follow and simple to add undesired one.
  • Model in terminology of clean architecture is not just an object that contains data.

UI layer is a bit of a complicated, but looks nice. Yet, it tells that it has more properties of MVVM approach than clean architecture. I wouldn't try to set up some definitive clean architecture repo for 2 reasons:

  1. Such projects tend to be too small to demonstrate issues that approach solves, instead they only illustrate that it is an overkill to do so.
  2. Narrowing idea to a set of concrete implementations, consisting a lot from almost never used (and needed) protocols and DI containers, means loosing it - clean architecture is not about concrete solutions, it is about properties of the system.
3 Likes