Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: clean architecture, boundaries and reactive frameworks #56

Open
jrmybrault opened this issue May 3, 2021 · 2 comments
Open

Comments

@jrmybrault
Copy link

Hello !

I just discovered your work through this breakdown https://nalexn.github.io/uikit-switfui/ and followed my way up to here :). First of all thank you for this very well articulated article. While reading it, I was thinking "yes.. yes... oh yeah ! been there, see what you mean... totally agree and very-well phrased... this guy is on point !"
I especially loved this part:
"Nevertheless, there is a heck of a lot of business logic running on modern mobile apps, but that logic is different. It’s just more focused on the presentation rather than on the core rules the business runs on.

This means we need to do a better job at decoupling that presentation-related business logic from the specifics of the UI framework we’re using."

Still, one thing "surprised"/"puzzled" me a bit, regarding clean architecture. On one hand you seem very prone to raise a strict boundary between the presentation layer & the "domain/core layer" (even for simple use cases that fetch data from an abstract repo), pushing UIKit / SwiftUI specificities to the outer limits, where they belong. Basically, if it's a framework then I don't want it to be polluting the core of my app.
Yet, you don't seem reluctant or bothered at all to "let" a reactive programming framework (be it an Apple "stamped" one like Combine or worse, a third-party one like Rx) going through pretty much everything, from data fetching to use-cases to presentation to ui. I'm sure this is a totally deliberate choice so I'd be glad if you can share some thoughts on that. For instance, did you ever considered preserving your core as strictly 100% vanilla Swift and plug the rest of the system through reactive adapters to this core ? Do you feel it's not worth it ?
In a fictive scenario where Apple's Combine isn't quite "bridgeable" to Rx, because their respective philosophy differs a bit too much, this could be very damaging, don't you think ?

@nalexn
Copy link
Owner

nalexn commented May 3, 2021 via email

@jrmybrault
Copy link
Author

jrmybrault commented May 4, 2021

Hello Alexey,

thanks for your answer. That's a very interesting take indeed.

I guess I have an harder time trusting vendor, whoever they are, especially when their APIs tends to propagate like crazy. But in a sense, RxSwift has quite a number of years behind it now and will probably not disappear tomorrow, I'll give you that. Yet I'm pretty convinced that RxSwift will not survive Combine, in the long run.
Obviously, the larger the codebase is, the larger that concern is. In a very large codebase where Rx is implied pretty much everywhere, maintenance and evolution are clearly at stake: updating to a newer version of the library becomes daunting, especially when some breaking changes are involved. In my experience, it tends to freeze until no longer possible, and you often ends up with huge migration/update project that will be boring yet risky, without clear time horizon.

Your point on the "surface" of the API is also very relevant. And that's precisely another reason I found common reactive programming libraries very "invasive", as their APIs are generally large, considering their "initial" purpose. You got the basics (observable / observer), the stuff you can't really ignore (disposable, bags, schedulers, ...) then a good deal of traits, all of that floating in an ocean of operators. Even when the library is narrower and more dedicated (as Combine is, compared to RxSwift), people often fall into adding some extensions library to "fill the gap". That's not mandatory of course, as using Rx traits is not mandatory, but the temptation is surely there to, as you say, "go all-in". When dealing with single event flows, which is frequent, I find Promise/Future libraries much more compelling and relevant, with a much more reasonable API surface.

Anyway, you clearly have a case for using a self-made, minimalistic, library. That's a nice thing to have in your bag 🙂 !

Regards,

Jérémy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants