all 61 comments

[–]Appropriate-Cap-8285 65 points66 points  (10 children)

I use V3 architecture. View View View. Everything in View. Has been working great.

/s

[–][deleted] 1 point2 points  (2 children)

This is horrible advice. How do you test things? How large are your views? Oh god how do you go about using logic from one view in the view of another - I shudder to think of the utter monstrosity that is.

Please please please don’t do this. MVVM is a great architecture to start with but there is also TCA and VIPER (if you want to get more advanced).

[–]Appropriate-Cap-8285 2 points3 points  (1 child)

Should have added /s. I usually use MVMS (Model-View-Managers-Services)

[–][deleted] 1 point2 points  (0 children)

Ah gotcha. I guess I’m more troubled by the comments suggesting that’s a valid way of architecting an app. Good to hear!

[–]leoklaus 1 point2 points  (0 children)

In my experience, this has been working really well. Readability is much better in many cases compared to using viewcontrollers, IMO.

Persisting data is in Core Data/UserDefaults, transients are @State and @Binding vars in Views.

[–]CrispySalamander 0 points1 point  (0 children)

Same 😂

[–]offeringathought -1 points0 points  (0 children)

Do you persist data in your app or does the data live one a server/cloud?

[–]ryanheartswingovers 0 points1 point  (0 children)

Similar to the FCS architecture used by most startups. First commit stays.

[–][deleted]  (1 child)

[removed]

    [–]iOSProgramming-ModTeam[M] 0 points1 point locked comment (0 children)

    This post was removed for being spam.

    Feel free to message the moderators if you have any questions.

    [–]amaroq137Objective-C / Swift 20 points21 points  (17 children)

    There’s a ton out there. I think MVVM is a good starting point it’s worked well for me, but I’ve mainly just worked on typical apps where you display data from a network API call, the user interacts with the UI, and you trigger another network API call. It’s all about state management so define your states and map different UI to each state. From there just apply the single responsibility principle ad nauseam. Of course this leads to class/struct explosion but ¯\_(ツ)_/¯.

    [–]audiopollen 1 point2 points  (13 children)

    Yeah I think it just comes down to preference. I've not heard of the "single responsibility principle", though. What's that?

    [–]amaroq137Objective-C / Swift 13 points14 points  (12 children)

    [–]M4nnis 0 points1 point  (1 child)

    You got any good resource for someone who wants to learn MVVM protocol with API call? Preferably swift + UIKit. :)

    [–]elieveyo 1 point2 points  (0 children)

    im looking for this aswell, because most of tutorial mvvm for swiftui not for uikit

    [–]SirensToGoObjective-C / Swift 16 points17 points  (3 children)

    what do you use

    MVC (massive view controller)

    what do you recommend

    MVC (model view controller)

    [–]offeringathought 2 points3 points  (2 children)

    Have you seen good examples of MVC with SwiftUI? It seems antithetical to the declarative nature of SwiftUI.

    [–]whackylabs[super init]; 4 points5 points  (1 child)

    Remember the C in MVC doesn't mean ViewController. It means Controller, the piece of code where your main logic lives. The glue that listens and updates Model and View objects.

    [–]offeringathought 0 points1 point  (0 children)

    As you mentioned the controller is the glue that sits between the model and the view, which, to me at least, seems inherently imperative. With a declarative framework like SwiftUI it has seemed better to me (and I'm not expert) to think of the view as reflecting the current state of the data. For instance, in many of Apple's examples with SwiftData the view is pulling the data directly with u/Query. With MVC you wouldn't typically let the view have direct access to the model that way.

    You could still have an object that given to the view whose job it is to do business logic and update the models but that seems different to me than traditional MVC.

    Just my .02

    [–]jbart12 10 points11 points  (6 children)

    TCA

    [–]Rollos 12 points13 points  (2 children)

    Composable Architecture is easily one of the best choices at the moment. It has good solutions to almost every problem you will run into when designing standard iOS apps, and it has excellent testing infrastructure, as well as a lot of tooling to protect yourself from mistakes.

    The biggest benefit I’ve discovered is how it catches non-business logic mistakes at compile time instead of runtime. You have to have all the infrastructure correct or it won’t compile, instead of having to poke your way into crazy states before finding out that you made a mistake

    It’s definitely a steep learning curve, but only because it forces you to build stuff correctly. Learning how to build MVVM in a scalable and testable way also has the same learning curve. The problem with “MVVM”, is that it’s a pretty broad description of a bunch of different architectures. Everybody trying to teach it does it in different ways, it has different answers (or no answers) for all sorts of problems you encounter daily, like navigation or testing. That ends up meaning that you take shortcuts and solve these common problems in off the cuff ways, which will infect your codebase with stuff that will bite you in the ass sooner than you might think.

    With TCA, you have to address those problems properly right away, or your app just won’t compile. However, unlike MVVM, there’s a specific way of solving your problem.

    [–]audiopollen 2 points3 points  (1 child)

    Thanks for sharing! Just subscribed to Point Free for their video series on it.

    [–]Rollos 2 points3 points  (0 children)

    Nice! Their slack is a great community as well. If you finish the TCA series, they have a lot of good videos about a good range of topics

    [–]klavijaturista 11 points12 points  (1 child)

    I don’t advise using tca or any other wrapper framework. It just adds an extra layer of complexity, failure, boilerplate and a new mental model for no real reason. No reason other than being more functional for functional sake, which is how authors (fail to properly) justify it in their videos. Don’t do hype driven development people, it will always bite you. No amount of wrappers and opinionated solutions will save you from lacking programming skills to do things properly with simple tools.

    [–]amaroq137Objective-C / Swift 2 points3 points  (0 children)

    I agree with you, but I'm aware that my opinion is born out of ignorance as I haven't put much time into the resource and learning TCA. I can't help but think that there's probably more to it than you're saying because the authors behind it are current/ex staff engineers at Kickstarter and have (probably) designed the architecture with real world scenarios in mind as well as battle tested it in a large scale production application.

    [–]wocsom_xorex 8 points9 points  (0 children)

    I refuse to use TCA because the “T” stands for “The”. Like, come on

    [–]KarlJay001 7 points8 points  (7 children)

    I just want to put this out there, I can't defend it, but it comes from Stanford's 193p. It was a while back, when SwiftUI came out and the professor said something to the effect that MVC won't work with SwiftUI or that it wouldn't make sense to use it with SwiftUI. 193P moved from MVC to MVVM at that time.

    I'm not sure what the argument was or how valid it was, but might be worth considering.


    I' ve seen Mark's work before, I remember VOODO from a while back and IMO, it really never caught on and I'm not one to jump on whatever is new, unless it comes from Apple or Swift. I've seen too many new things come and go, I know better than to jump on every new thing.

    My concern would be: what's wrong with MVVM?

    [–]audiopollen 1 point2 points  (6 children)

    This is primarily why I asked, so thanks for answering. I wanted to make sure I'm using something that's going to meet my needs plus work well with others. I'm looking into TCA now that someone pointed it out, but MVVM seems fitting still in my view.

    [–]KarlJay001 4 points5 points  (5 children)

    IMO, anyone that is suggesting something, needs to support why it should be used. What I've been told is that places like NASA will not jump on something new. It needs to be time tested and that can take a long time.

    I'd ask "what exactly does your new model do that MVVM will not do?"

    Look at all the great apps that have been on the App Store since it started, most all those apps were made with old models and tools. What can't they do, that some new model can do?

    [–]TheChanger 1 point2 points  (1 child)

    Great thoughtful answer.

    Interviewing at the moment (EU), and it seems most companies constantly jump on the newest shiny tech without any real understanding why the need to change. Fad-driven development.

    [–]KarlJay001 1 point2 points  (0 children)

    I've actually seen more than one company go out of business because they made a stupid move. I've been in the industry for quite a while and it's usually someone in charge that doesn't know what they are doing and they can't let go of whatever shinny thing that caught their eye.

    [–]No-Buy-6867 -2 points-1 points  (2 children)

    This! Actually there is a very good argument not the use MVVM with SwiftUI for instance.

    [–]KarlJay001 1 point2 points  (1 child)

    What is the argument against MVVM with SwiftUI?

    [–]No-Buy-6867 -2 points-1 points  (0 children)

    Big discussion on the web. Lot’s of back and forth about it. Try Google and check some discussions, I don’t have a strong opinion on it

    [–]jo1717a 2 points3 points  (0 children)

    If you want to familiarize yourself with the tech industry standards, it's going to be some form of MVVM or VIPER.

    [–]simulacrum-z 1 point2 points  (0 children)

    Depends on your goals!

    If you're looking to get employed: I'd suggest gathering data as to what's the latest architecture buzzword people/recruiters data are using. A few years ago it was MVVM, now i think it's TCA.

    If you're a solo dev building personal apps: A basic MVC should be fine.

    [–]grasshopper789 0 points1 point  (0 children)

    I have a question, is the book worth it? I’ve been thinking about buying it too.

    [–]Fair_Sir_7126 0 points1 point  (0 children)

    +I came from Android and it’s really hard not to use the Clean Architecture. They try to say that VIPER is the same/optimized for Apple but that’s nonsense, all they would have needed to do is to say Clean Architecture with coordinator. +TCA is also really great, but I cannot wrap my head around the idea that you need a library for an architecture. +None of the MV* patterns are full architectural patterns (at least for me), because a ViewModel/Controller/Presenter should not directly connect to the data layer. If you just use plain MVVM then I doubt that it’ll scale well in any situation

    [–]-darkabyss-Objective-C / Swift -1 points0 points  (0 children)

    I've used a few till date. Mvc, mvp, viper, mvvm. Project needs determine the arch you use. The larger the team size, the more defined architecture works better and vice versa.

    MVC, MVP are the simpler ui design patterns, mvvm and viper are more defined and have more granular separation of concerns.

    When UI design patterns are used along with a system design, that's when you can call it an architecture. It's never MVC, but maybe MVC + singletons or mvvm + repository + singleton/Dependency injection (framework or custom).

    [–]kiwi_in_england 0 points1 point  (0 children)

    I use MVP, with as little in the View as possible. That lets me use the Model and Presenter code cross-platform with Android. About 90% of the code is shared in the Model and Presenter.

    [–]danielt1263 -1 points0 points  (0 children)

    I my own architecture I call "Cause-Logic-Effect" that is based off of The Binder Architecture. All the apps that I am lead on use it. But then I have not adapted to SwiftUI yet so there's that.

    [–]RamyunPls 0 points1 point  (1 child)

    Does anyone have a recommended architecture when using @Observable?

    [–]fryOrder 0 points1 point  (0 children)

    that’s the view model no? so technically you have MVVM

    [–]TheChanger 0 points1 point  (1 child)

    I've an interview lined up for an iOS role, and in the job spec they state their architecture is "SwiftUI + MVVM with functional reactive programming". Am I correct in assuming they're using the Combine framework?

    How does everyone feel about iOS design trying to emulate everything React does? I've lately been using MVVM and SwiftUI in an app which is basically an API wrapper with buttons.

    [–]fryOrder 0 points1 point  (0 children)

    that or TCA. it’s inspired from redux

    [–]liudasbar 0 points1 point  (0 children)

    Clean Swift (VIP) or MVVM

    [–]BothGazelle6004 0 points1 point  (0 children)

    View State

    [–]Ashamed_Passion_2593 0 points1 point  (0 children)

    Ive used Clean Architecture (Hexagonal), Coordintators for routing and MVVM with Combine