STOP using MVVM for SwiftUI | Clean iOS Architecture

STOP using MVVM for SwiftUI | Clean iOS Architecture

Rebeloper - Rebel Developer

2 года назад

29,044 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Rebeloper - Rebel Developer
Rebeloper - Rebel Developer - 26.07.2021 11:29

What is your favourite Design Pattern in SwiftUI?

Ответить
Fulvio Fagnani
Fulvio Fagnani - 19.08.2023 21:18

Very interesting. Just wondering how this would simplify getting automatic coredata database updates that @FetchRequest offers
Thanks

Ответить
Raptisha
Raptisha - 25.07.2023 23:17

Can't understand the point of this video. You've described the mvvm pattern.

Ответить
Nat Serrano
Nat Serrano - 16.05.2023 19:46

can you do a video about TCA architecture>?

Ответить
imfractured
imfractured - 28.03.2023 15:18

He’s just creating flat scopes that will inevitably cause massive memory and scoping issues for redrawing once you have to add more than a single screen to your test app. Would not recommend doing anything similar to this. There’s really no pattern here, and the way he’s managing the view model makes me think he doesn’t even understand why you’d want a view model in the first place or how you’d write tests to cover this monstrosity

Ответить
Ömer Bayrak
Ömer Bayrak - 28.03.2023 15:13

Well, I learnt how mvvm works thanks to you.

Ответить
Ugo
Ugo - 27.03.2023 23:14

I think the author’s efforts in making tutorial videos are helpful for the most part, but going by this video he is completely leading new and inexperienced SwiftUI developers down a rabbit hole filled with frustrations.

There’s absolutely no advantage to doing this “pattern” over MVVM. One of the main reasons for these UI patterns is to make it easy to implement automated tests on the code base, but he didn’t even demonstrate how this “pattern” of his makes it easier to test.

Meanwhile, why do you use optional/nil parameters for the “UserProfile” struct initializer instead of just using a more idiomatic default initializer/method parameter values?

All in all, thank you for making this video but I advise other watchers to be more circumspect with what they “learn” from it.

Ответить
Jonathan Sack
Jonathan Sack - 25.03.2023 16:02

Just curious: with this approach, how do you handle the case where one observed resource needs to be shared and observed by multiple views ?

Ответить
gNoyL
gNoyL - 02.02.2023 22:34

It is really distracting to watch you look at keyboard every time you type something. Stoping in middle to check what you write and then keep writing. How many years of experience do you have in order not to be able to type without looking at your keyboard?

Ответить
Jim Lambert
Jim Lambert - 30.12.2022 00:40

So just Model, View, ViewModel EXCEPT we call it Identifiable, View, Observed. GENIUS.

Ответить
Jonny Jones
Jonny Jones - 26.12.2022 18:17

Came here for the comments. Another clickbaity video. MVVM all the way. Don’t respond with a link to another video like you do with all your other replies thanks

Ответить
Manuel De freitas
Manuel De freitas - 06.12.2022 18:56

What about when using concurrency (async/await)? How does that work with IVO?

Ответить
DardanAirlines
DardanAirlines - 19.10.2022 08:43

You seem to be promoting MVVM, even though you say otherwise. One of the hallmarks of MVVM is testability, and I find it odd that the folks taking the time to write articles about why MVVM doesn't work with SwiftUI, conveniently leave out how one might otherwise unit test their code.

Ответить
Keke Arif
Keke Arif - 18.10.2022 15:20

This is just MVVM renamed

Ответить
Wes Grimes
Wes Grimes - 24.09.2022 02:12

Love this refinement on the MVVM pattern. I’ve implemented similar patterns in Angular2 in the web side.

Nice walkthrough Alex!

Ответить
Oleg Kovtun
Oleg Kovtun - 12.09.2022 17:23

Looks like MVVM with a different naming ) But anyway, thank you for the video )

Ответить
Yan Rodriguez
Yan Rodriguez - 26.08.2022 22:58

Please stop using the clean architecture label in this videos. This is just MVVM with makeup

Ответить
Anton nel
Anton nel - 23.08.2022 07:55

If you return something that is unstable, like UUID() or an index, this means you get a new object each time you get the object and this will kill reusability and can cause epic memory and layout process usage beside view management issues like transition management and etc.

Ответить
Martin Regas
Martin Regas - 20.08.2022 01:39

Hello, thanks for the explanation, I applied it in a demo that I am making to practice SwiftUI, but I have a doubt,
Could you give me an example of where I should declare an EnviromentObject? would it be inside the View or inside the Observed class?

Ответить
Leonids Tech Learning
Leonids Tech Learning - 13.08.2022 22:30

Can you show us how to write Unit Tests with this pattern?

Ответить
indomitableTR
indomitableTR - 13.08.2022 15:47

i heard is first time, from you, thank you to make us noticed

Ответить
azamsharp
azamsharp - 21.07.2022 22:10

I agree! View in SwiftUI is the View Model.

Ответить
MrMassmaker
MrMassmaker - 09.07.2022 21:42

how about the memory cycle in Observed's completion ?)

Ответить
Lun Wang
Lun Wang - 09.07.2022 20:51

the init func is really a bad practice,
why not give Date() instead of nil as the default value

Ответить
Николай Ник
Николай Ник - 08.07.2022 19:49

As my opinion this approach is bad shit. We can use only VM (veiw, model) for SwiftUI app.

Ответить
MaximG
MaximG - 13.05.2022 23:57

How?! How did you change -> to an arrow?

Ответить
WilfClegg
WilfClegg - 06.05.2022 09:31

Thank you for this tutorial. It is the cleanest and easiest to understand. I've viewed many MVVM tutorials, and they are usually convoluted by using components that detract from the basic inter-file communication. This makes it more overwhelming to visualize. Your example is straight and to the point, with no distracting "extras". I also really like your teaching style, and look forward to following more of your tutorials. Thanks again!

Ответить
Federico Torres
Federico Torres - 15.04.2022 15:58

How would you share an observed object between several views?

Ответить
Paul IKhane
Paul IKhane - 09.04.2022 03:26

Why I like the concept for it simplicity it may end up creating difficulty for a medium or large project. The layers are tightly coupled so maintaining the code will become a big issues quickly. I always advocate for separating business logic from every other layer/part of your code and business layer should never depend on any concrete implementation of any other part of your code.

Ответить
Franco c
Franco c - 06.04.2022 06:15

It might work for small projects. But for medium and big projects, with thousands of business rules, it will just fail miserably.
MVVM remains the best choice for any iOS project, specially big ones.

Ответить
Jonas Šimkus
Jonas Šimkus - 27.03.2022 22:22

There is no difference from MVVM and what you've described here apart from just putting a different label/name and made such a big claim to "STOP using MVVM". Was expecting at least some challenging arguments and new solutions exclusive for SwiftUI. We us this in our projects.

Ответить
AntiSmithhh
AntiSmithhh - 20.03.2022 19:33

looks like renamed MVVM with outdated GCD

Ответить
Mahmoud Alsamman
Mahmoud Alsamman - 23.02.2022 12:01

IMO You just renamed ViewModel class in MVVM to Observed

Ответить
Aleksei Lobankov
Aleksei Lobankov - 09.02.2022 17:23

Besides the naming and nesting one type into another, how exactly this pattern differs from a regular mvvm?

Ответить
Andy Bezaire
Andy Bezaire - 06.02.2022 17:04

Why does struct Profile have to be Identifiable ?

Ответить
David Nitzsche-Bell
David Nitzsche-Bell - 04.02.2022 03:13

This looks very interesting. Will try it out.

You almost addressed something which I've been struggling with, so I'll ask you here..... Hope you don't mind.

Many apps have a sign-up/sign-in ability and then a User Profile page that can be filled in. But....what if the properties in the User struct are optional? Mine has `name` and `email` as Strings, but then I have 5-10 other properties which are all optional: dateOfBirth: Date?, gender (an optional Enum), heightInCM (optional Int), and more. Following Peter Friese's Books app, I like the idea of having one view to display the User Profile and clicking "Edit" to update the User's properties. But, if the user edits their profile but only adds one value, say their birthdate, and doesn't change the other values, how will they maintain their nil values? I can fake it for anything that uses a TextField, but for Pickers, Toggles, etc....there doesn't seem to be a useful, non-clunky solution.

If you have any thoughts, ideas, suggestions - even other places I could ask that are not as judgemental as SO - I'd be happy for any pointers.

Thanks again for you interesting video.

Ответить
thomaswilson1111
thomaswilson1111 - 04.01.2022 20:16

Going to try to use IVO for my second app. Wish me luck!

Ответить
Bob Weiram
Bob Weiram - 26.11.2021 09:22

Why did you use an optional value instead of a default parameter value?

Ответить
Charles Chen
Charles Chen - 17.09.2021 21:17

No offense but i feel like put functions in the views kind of messy to me , I prefer mvvm I’d say

Ответить
PawelPow
PawelPow - 02.08.2021 12:22

This is basically MVVM but the Model has to be identifiable and the view model is inside the View

Ответить
Scale Coding Skills
Scale Coding Skills - 29.07.2021 15:59

which Xcode theme you are using, it looks decent and clean.

Ответить
K K
K K - 29.07.2021 03:21

Can the identifiable be a Core Data Entity?

Ответить
Krystian Solarz
Krystian Solarz - 28.07.2021 16:42

Hmm interesting : ) what about navigation?

Ответить
Samuel Folledo
Samuel Folledo - 28.07.2021 16:02

HI Rebel! Im new-ish in iOS dev, curious to know use cases for this pattern? Should I use this for my job or personal project? I do like how this reduces the amount of models (or view models) to create especially if the Model or ViewModel is for that specific View only while at the same time easier to set up in the beginning.

This almost feels like MVVM, with the difference of naming and access. Is this still easy to test?

Ответить