Clean iOS Architecture pt.5: MVC, MVVM, and MVP (UI Design Patterns)

  Переглядів 112,493

Essential Developer

Essential Developer

5 років тому

★ Register Now to Our Free iOS Career Course! www.essentialdeveloper.com/co...
Subscribe to our channel: ukposts.info...
In this video, we're going to explore the main differences between the MVC, MVVM, and MVP design patterns.
We’ll start with a quick recap of the MVC, MVVM and MVP history and move to modern days where we’ll explore ideas on how we can apply those patterns in iOS applications with UIKit. Finally, we’ll discuss why none of those acronyms can be considered a software architecture, but just UI design patterns.
For more, visit the Clean iOS Architecture Playlist • Clean iOS Architecture... .
★ Professional iOS Engineering S01
Take your skillset to the next level and boost your career www.essentialdeveloper.com/pr...
★ Download our new app
You can download Neat Trivia from the App Store today at itunes.apple.com/app/id125311....
Connect with us on:
• Website: www.essentialdeveloper.com
• Twitter: / essentialdevcom
• Facebook: / essentialdeveloper

КОМЕНТАРІ: 76
@guindows
@guindows 4 роки тому
The best explanation ever. Direct, talking not only about the views, but included the other parts of the application as well (networking, parsing routing...), which most of other videos don't even mention about it, and very good and clear graphics. Well done mate. Thank you.
@EssentialDeveloper
@EssentialDeveloper 4 роки тому
Thank you!
@rosey182
@rosey182 3 роки тому
I thank you for your clear and simple explanation. Grrrrreat job! Not a second wasted on fluff just the good stuff!
@kampolovna
@kampolovna 4 роки тому
very nice and concise explanation, thank you for the video!
@giuseppemorana7168
@giuseppemorana7168 5 років тому
Thanks, I think this is one of the clearest tutorials on the web which explains these patterns and how are applied to the iOS platform. Really liked to see how the original MVC is different from the Apple implementation and how all those patterns are very similar between them :)
@EssentialDeveloper
@EssentialDeveloper 5 років тому
Thanks, Giuseppe! Glad to know you enjoyed and learned from our content. ✅⛩
@irjayjay
@irjayjay 5 років тому
Thank you, so many crappy tutorials out there that are poorly written or recorded. Yours was the best!
@watchit387
@watchit387 3 роки тому
yeah tell me about it, I don't know why everyone started thinking that they can teach
@AmanKumar-hr5dc
@AmanKumar-hr5dc 4 роки тому
Very nice video!!!!!!!!!!!! At last, I finally understood these design patterns and the difference between MVC and MVVM clearly!!!!!! Thank you so much!!!!!!!!
@EssentialDeveloper
@EssentialDeveloper 4 роки тому
Hi Aman Singh, thanks for the feedback! We're thrilled to know you've learned with our content. ✅ Happy coding! ⛩
@MrVipulLal
@MrVipulLal 3 роки тому
Great stuff, mate. Clear , concise and comprehensive! Kudos
@EssentialDeveloper
@EssentialDeveloper 3 роки тому
Glad you liked it!
@mnesvat
@mnesvat 2 роки тому
One of the best and cleanest explanation thanks
@abdallashawkyabdo2721
@abdallashawkyabdo2721 Рік тому
perfect explanation, especially you mentioned the problem of MVC from the beginning of its evolution :)
@EssentialDeveloper
@EssentialDeveloper Рік тому
Thanks! Glad you liked it 🙂
@quickfingers5982
@quickfingers5982 3 роки тому
This is really great. Do you have an example of this, with all the layers you have (networking, routing, parsing, rendering..)?
@EssentialDeveloper
@EssentialDeveloper 3 роки тому
Hi! Yes, we cover all of those in the iOS Lead Essentials program: academy.essentialdeveloper.com - I also recommend this series on UKposts www.essentialdeveloper.com/professional-ios-engineering-series
@Maw0822
@Maw0822 4 роки тому
Best tutorial on this topic I have found by far
@EssentialDeveloper
@EssentialDeveloper 4 роки тому
Thank you!
@swiftandtips
@swiftandtips 2 роки тому
Wow, your explanation of those three patterns is amazing! Thank you so much! 👏🏼
@kitegames3351
@kitegames3351 3 роки тому
Great , awesome presentation
@Korupt0
@Korupt0 3 роки тому
hi. Great video. thank you. please can you tell me what software you used to create your diagrams?
@EssentialDeveloper
@EssentialDeveloper 3 роки тому
Thank you! It's draw.io
@flytoo8055
@flytoo8055 Рік тому
@@EssentialDeveloper thanks!
@HashemRC
@HashemRC 4 роки тому
I'm wondering why after one year I'm finding your tutorials and website?! great content and descriptions.
@EssentialDeveloper
@EssentialDeveloper 4 роки тому
Thank you and welcome to the channel! ✅
@HINDISE_ENGLISHTAK
@HINDISE_ENGLISHTAK 3 роки тому
Thanks for the video, As you explain MVC, MVP MVVM and VIPER are UI Design Pattern then what is Arachtechtural Pattern in iOS?
@EssentialDeveloper
@EssentialDeveloper 3 роки тому
Those are considered UI architectural design patterns, but they're not software architectures. Software Architecture is something else. Keep watching the series to learn more ✅
@mohamednidhalmrad1228
@mohamednidhalmrad1228 2 роки тому
thanks a lot. it's very nice video. can you please explain the other design pattern clean swift and VIPER?
@EssentialDeveloper
@EssentialDeveloper 2 роки тому
Hi Mohamed, watch parts 6 and 7 in this playlist: ukposts.info/have/v-deo/e5uqoKidgqyXknU.html
@mohamednidhalmrad1228
@mohamednidhalmrad1228 2 роки тому
Thanks 😊 you are awesome 😎
@xaviercp2200
@xaviercp2200 4 роки тому
the best explanation ever
@EssentialDeveloper
@EssentialDeveloper 4 роки тому
Thanks! Glad to know you enjoyed and learned from the content ✅
@xaviercp2200
@xaviercp2200 4 роки тому
Just a little question. WPF was designed under MVVM or MVP ??
@EssentialDeveloper
@EssentialDeveloper 4 роки тому
You can use both. The XAML binder makes MVVM more convenient.
@FunnyRoom
@FunnyRoom 3 роки тому
Good explanation, thank you
@EssentialDeveloper
@EssentialDeveloper 3 роки тому
Glad it was helpful!
@Felip38rito
@Felip38rito 3 роки тому
Hey Caio, thank you for all the tips. I was stuck in MVC (apple) and no matter how I was separating things, one layer was always doing too much as you've said. Now I'll have another paths to go :) Thanks mate. (PS: Você é brasileiro? Deu pra sentir pelo sotaque... Um abraço cara! :D)
@EssentialDeveloper
@EssentialDeveloper 3 роки тому
Hi Felipe, glad it was helpful! Yes, I'm Brazilian 🇧🇷
@Omfe6
@Omfe6 7 місяців тому
oh wow All this time I though you were Italian LOL@@EssentialDeveloper
@nazirjama6331
@nazirjama6331 Рік тому
thanks, man this helped me a lot
@EssentialDeveloper
@EssentialDeveloper Рік тому
Glad to hear it!
@raulsilvamx
@raulsilvamx 3 роки тому
Hi! I'm asking to all... What is the name app to make those workflow mockups? Looks amazing I would use it.
@EssentialDeveloper
@EssentialDeveloper 3 роки тому
Hi! We use draw.io
@americanaccounts
@americanaccounts 4 роки тому
Thank you very much. I would be interested how SwiftUI influences the selection of a UI pattern. In my option Apple released with SwiftUI a MVVM solution. So, in the next two years iOS 13 definitely is the default version on every iPhone. Therefore MVVM will be the new MVC. Would do you think?
@EssentialDeveloper
@EssentialDeveloper 4 роки тому
MVVM works well with SwiftUI, due to the built-in bindings. It works fine with other patterns too. ✅
@EssentialDeveloper
@EssentialDeveloper 2 роки тому
Hello! We meant State, StateObject, ObservedObject, etc.
@EssentialDeveloper
@EssentialDeveloper 2 роки тому
We teach it in the complete iOS Lead Essentials program. Check it out: iosacademy.essentialdeveloper.com/p/ios-lead-essentials/
@EssentialDeveloper
@EssentialDeveloper 2 роки тому
Hello. You don't need to follow the cohort schedule - it's optional. You can go through the program at your own pace.
@isurujn
@isurujn 2 роки тому
Hi, I have seen MVP tutorials where some offload things like showing an alert over to the presenter. And in some tutorials, they advice against that practice and recommend keeping the presenter UI-agnostic and have it only handle business logic. I know there is no silver bullet, 100% correct way to these things. But personally, what do you think is the better approach? Should the presenter have UI code in it or not?
@EssentialDeveloper
@EssentialDeveloper 2 роки тому
Hi Isuru! We prefer to make the presenter UI-agnostic if possible. This way, it's easier to use it in different UIs, frameworks, platforms, or apps. It's also easier to test it without the UI. Moreover, business logic ideally goes in a business domain layer. The presenter performs only presentation logic, such as formatting dates, numbers, etc. ✅
@isurujn
@isurujn 2 роки тому
@@EssentialDeveloper Gotcha! Thank you for the explanation and the prompt reply 🙏🏼
@osucaru009
@osucaru009 3 роки тому
You have a new subscriber dude
@EssentialDeveloper
@EssentialDeveloper 3 роки тому
Welcome on board!
@prabirkumar8027
@prabirkumar8027 5 років тому
sir, please do collectionview inside tableview using mvc
@devarajn5910
@devarajn5910 5 років тому
Great video to understand these patterns, thank you. Can we have PDF document with each of these design pattern's diagrams? For those who are looking for diagrams, check video on timings below.(Alert: but make sure you go through video, Since all these patterns doesn't concern about database operation, networking etc. they can be put in Model or Controller based on your convenience ) MVC : 7:43 MVVM: 9:54 MVP : 12:19 MVC, MVVM with UIKit : 13:32 MVP with UIKit : 14:20
@EssentialDeveloper
@EssentialDeveloper 5 років тому
Thank you! You can find the diagrams at www.essentialdeveloper.com/articles/clean-ios-architecture-pt-5-mvc-mvvm-and-mvp-ui-design-patterns ✅⛩
@devarajn5910
@devarajn5910 5 років тому
@@EssentialDeveloper thank you :) appreciate it.
@amrzayed4545
@amrzayed4545 5 років тому
what is the best in ios MVVM or MVP?
@EssentialDeveloper
@EssentialDeveloper 5 років тому
Hey, we don't believe one is better than the other. MVVM is more popular than MVP in the iOS community, so it can be easier to find content about MVVM. However, we recommend you to learn both so you can choose the appropriate pattern to solve different problems. Happy coding! ✅⛩
@doug8171
@doug8171 5 років тому
Could you add some example simple but representative public github example projects for these various architectures so we can connect the diagrams to what it looks like in code?
@EssentialDeveloper
@EssentialDeveloper 5 років тому
Hi Doug, thanks for the suggestion! We'll be covering examples in the future. ✅⛩
@Tobool
@Tobool 5 років тому
Hello, thanks for this new video. One comment that I think should be added is to explain why people keep implementing MVVM though it looks like MVC+boilerplate - because VM doesn’t depend on UIKit and it is easier to test.
@EssentialDeveloper
@EssentialDeveloper 5 років тому
Hi Piotr, thanks for sharing this! The Presenter in the MVP design pattern also doesn't depend on UIKit and can be tested in isolation. ✅
@wayneosaur
@wayneosaur 7 місяців тому
So the controller didn't disappear when going from MVC to MVVM ... it's duties are just passed off to the the view and viewmodel? The controller orchestrates the interaction between view and model -- what is doing this orchestration in MVVM?
@EssentialDeveloper
@EssentialDeveloper 7 місяців тому
Hi! MVVM is based on the Observer pattern, where ViewModels expose Observable properties that can be connected with the Views directly (the observers are usually done through simple closures or popular frameworks like Combine/RxSwift). With Observable properties, once the ViewModel state changes, the Views can be updated immediately and directly without an intermediary. The same on the other direction: when there's input from the User through the Views, it can also be passed to the ViewModels directly without an intermediary based on bindings. Frameworks like SwiftUI bind View and State automatically and seamlessly without the need for a Controller. When following MVVM in SwiftUI, the ViewModel can be the View State, so they are kept in sync automatically without a controller. But in UIKit, there's no automatic binding of the View and its State, so you could use the Controller as a place to bind the View with a ViewModel, for example.
@PavelPalancica
@PavelPalancica 3 місяці тому
I recommend watching "A Better MVC" by Dave Delong, an engineer that used to work on UIKit at Apple, and another talk "MVC is not your problem" by an engineer named Joachim Kurz. Sometimes responsibilities couild be mixed. We can even have controllers in the Model layer... for instance NotesController that loads some notes to be futher used to the ViewModel, and also to temporarily keep in memory the old and new text for a note in Editing Mode. One approach that few people talk about is that UIViewController is acting more like a view than a controller, therefore should belong to the View camp (instead of Controller). So we think of it that way - the Controller object was never really present in MVC, MVVM or MVP. Imo the Coordinator from the Coordinator Pattern is actually the Controller we'd need most fo the times to implement proper MVC. Think of it as the Controller or the CoordinatingController. It has direct refernces both on Views/ViewConrollers/ViewModel and Models. And View layer objects (mostly View Controllers) would still directly access Model directly (which is basically classic MVC). I don't understand why people are so concerned with Networking or Database Access not fitting in one of those categories in Model, View, ViewModel, Controller, or Presenter. All these UI architectures are more like minimum recommended layers or categories of classes etc. to organize our code into. It's a "phylosophy" so to say, and not a strict template to follow. If our app starts with local caching or storage - later add a folder named PersitanceLayer. If we need Networking - add a Networking or Web APIs folder. That doesn't mean MVC was not good enough and now we invented MVC+S, MVC+N or MVC+NS etc. And in many cases MVVM would not necessarily solve any problem we had with MVC (if View Models are lighweight structs - you could rename them to View Data and it's just some intermediary structures, and it's still same old MVC). And MVC is not the reason why we get huge VC files. It's programmer's fault for giving too much responsibiliities to VCs. Similarly we could give too much respnsibilities to VMs. Some people even make VMs dependent on UIKit, or add the Networking code directly in VMs, which is another bad practice. Model, as per MVC phylosophy - is the ultimate source of truth. I see the objects doing the Database Access or Networking - as helpers to bring the "truth" data from the server and keep it locally temporarily. From this perspective - those two belong to the Model (even though physically they belong to a different folder or module), so there should be no doubt that it should go to the Model or the Controller. I think the main idea we could get from all this UI design patterns - is Separation of Concerns. Over-obsessing over any of them is not really worth it. There are some amazing apps out there, written in MVC, and there are some awful apps, with huge codebases, but written in MVVM and VIPER.
@lifethreesixtydegree
@lifethreesixtydegree 4 роки тому
business logic is good to have with a model in the case of MVVM? isn't should be with viewModel? Eg. Showing a specific date format based business requirement totally should be calculated by ViewModel not by the model. correct me if I am wrong.
@EssentialDeveloper
@EssentialDeveloper 4 роки тому
Date format is *presentation* logic. We recommend you to keep presentation logic in the Presentation Layer along with ViewModels, Presenters, etc. Business models should ideally be in a higher-level module that doesn't depend on specific presentation/UI logic. ✅
@americanaccounts
@americanaccounts 4 роки тому
@@EssentialDeveloper Maybe it depends or not? When I have a specific date/distance/money format for my whole project then I would create extensions for the models. Then it is encapsulated and in the model. When I need some specific presentation logic for one view, I always would put presentation logic into the viewmodels, presenters, etc.
@EssentialDeveloper
@EssentialDeveloper 4 роки тому
Hello! We recommend you to separate business models from presentation models. So you can develop, maintain, extend, and test them in isolation. You will also be able to present the same Model differently, without complex/nested if-else logic. And decouple the UI from business models. The thing is: UI/Presentation logic and business logic often change for different reasons and by different stakeholders. So, separating them gives you more flexibility to change one module without affecting the other. This doesn't mean you need to duplicate code. You can reuse the presentation logic when appropriate. ✅
@CrackedRecords
@CrackedRecords 3 роки тому
So at the end MMVM is not solving anything that wasn't "working" on MVC just moved around, and as always the best scape is "you decide where you put it"
@radomyrbezghin6299
@radomyrbezghin6299 3 роки тому
Okay, then why none of them figures out where to put networking code ? They are basically 3 similar patterns that have exactly the same flaws ...
@EssentialDeveloper
@EssentialDeveloper 3 роки тому
They're not flaws - these UI patterns are just not meant to deal with networking. The networking lives in another layer, not the UI ✅
@PavelPalancica
@PavelPalancica 3 місяці тому
@@EssentialDeveloper - But who said we have many layers (to begin with)? Isn't it that most students are taught MVC way before being taught about Multi-Layered Architecture? From this perspective, in case when we just have the UI layer but we need to do some networking - MVC can be seen as app architecture, isn't it? And the Networking layer is just a helper component of the Model layer... Physically it can be a new folder or module, but logically - it's just a bunch of helpers needed to transfer "source of truth" data between client and server.
@EssentialDeveloper
@EssentialDeveloper 3 місяці тому
Hi @@PavelPalancica You can have as many layers as you want. It's up to you to decide what's best for your app ✅
Clean iOS Architecture pt.6: VIPER - Design Pattern or Architecture?
15:05
Essential Developer
Переглядів 36 тис.
[실시간] 전철에서 찍힌 기생생물 감염 장면 | 기생수: 더 그레이
00:15
Netflix Korea 넷플릭스 코리아
Переглядів 38 млн
Exploring UI Design Patterns: MVC, MVP, and MVVM
9:02
Andrey Tech
Переглядів 1,3 тис.
Clean iOS Architecture pt.7: VIP (Clean Swift) - Design Pattern or Architecture?
15:58
Everything You NEED to Know About Client Architecture Patterns
5:51
ByteByteGo
Переглядів 196 тис.
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Переглядів 2,1 млн
iOS Developer Mock Interview | Tech Round (Round-2)
31:37
iCode
Переглядів 5 тис.
5 Design Patterns Every Engineer Should Know
11:51
Traversy Media
Переглядів 929 тис.
MVP по SOLID c DI и Unit test на Swift 5 part 1
54:47
The Swift Developers
Переглядів 30 тис.