What Is the Best Architecture for Android Apps?

  Переглядів 52,737

Philipp Lackner

Philipp Lackner

Рік тому

In this video I'll ask one of the most commonly asked questions I get. Which architectural design pattern is the right for your app?
⭐ Get certificates for your future job
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:
pl-coding.com/premium-courses/
💻 Let me personally review your code and provide individual feedback, so it won't backfire and cost you a fortune in future:
elopage.com/s/philipplackner/...
Subscribe to my FREE newsletter for regular Android, Kotlin & Architecture advice!
pl-coding.com/newsletter
Join this channel to get access to perks:
/ @philipplackner
Join my Discord server:
/ discord
Regular programming advice on my Instagram page: / _philipplackner_
Checkout my GitHub: github.com/philipplackner
You like my free content? Here you can buy me a coffee:
www.buymeacoffee.com/philippl...

КОМЕНТАРІ: 99
@illusion9423
@illusion9423 Рік тому
I want to say. I've recently started to learn android and I think your presence and quality of your videos really makes this community. Your videos are detailed and they're great for learning from and you talk about all the relevant aspects of android and kotlin
@PhilippLackner
@PhilippLackner Рік тому
Thanks so much 🙏 ❤️
@haykmkrtchyan7093
@haykmkrtchyan7093 Рік тому
MVP vs MVC. MVP - In android the view and presenter use interfaces to talk with each other. It's based on callbacks. The view triggeres a function from the presenter interface. Presenter implementation changes the model, gets the result back, and triggers view interface function. The view itself implements that. ========> =======> View Presenter Model
@IronGuy21
@IronGuy21 Рік тому
Lol. Just today i've started choosing architecture and project pattern and you publishing this video. Amazing. Thank you so much. I've seen video about MVVM from you a couple days ago actually, and this is a great addition to it.
@shaiquekhan1185
@shaiquekhan1185 Рік тому
MVI doesn't cause whole UI to be updated with each state change. Each composable function keeps track of the arguments passed to them so when you call copy on the state. Only the Composables with changed arguments will get recomposed, not the whole UI.
@PhilippLackner
@PhilippLackner Рік тому
Speaking of compose, yes. Speaking of XML, it will always trigger the single flow collector which will re-compute all the UI logic. With compose I like MVI much more than with XML.
@shaiquekhan1185
@shaiquekhan1185 Рік тому
@@PhilippLackner yeah true that. Do you have any reference for handling race conditions in MVI? I have implemented MVI in a some of my projects and I had no idea about this disadvantage 🥲 now I wonder if it might break prod and will be really hard to find out
@PhilippLackner
@PhilippLackner Рік тому
@@shaiquekhan1185 could be an idea for a video. All in all, make sure to use StateFlows and use flow.update {} to assign a new value instead of state.value = state.value.copy() directly
@ubersticks
@ubersticks Рік тому
@@PhilippLackner This is an important point - it seems to tilt the scale more towards MVI for Compose projects.
@webdrizzled
@webdrizzled 11 місяців тому
I had the same doubt @Shaique Khan, Thanks for mentioning inside comments
@nipunshah1373
@nipunshah1373 Рік тому
Amazing gist on various architecture options available for Mobile Development. As per my understanding just making flutter analogy for aforementioned videos : MVVM => Provider/Riverpod (ie Stacked Archi) MVI => BLOC MVC => GETX Above analogy is just in my opinion for flutter dev to map the knowledge share in the above video during flutter development !
@kenali4612
@kenali4612 Рік тому
Been waiting on this one !!
@EricLouisYoung
@EricLouisYoung Рік тому
I'm a backend dev getting up to speed on android. I do CQRS on the backend with Elixir. The pattern is so good that I'll be doing it in android. Seems very close to what you're calling MVI... intents = (C)ommands, and the (Q) (reading state) is merely the view subscriptions to the live data that gets updated as a result of successful Commands.
@TheBlackManMythLegend
@TheBlackManMythLegend Рік тому
What I like about the videos of this awesome creator is that it's really good code and it's better than hello word. It's full of good practices. It's excellent for preparing for interviews( in my opinion) . It also increased my interest again for Android . ( as a 5 years experience android developer which means nothing if I don't push myself to learn new stuff or don't work in big teams in challenging projects, will start my first big team fintech job in august... So I am in the process to learn really good practice and that channel and his Github in my humble opinion are the go to place for me at the moment ) Very professional.
@PhilippLackner
@PhilippLackner Рік тому
Thanks for the kind words! Appreciated :)
@ClowneryCity
@ClowneryCity 5 місяців тому
Thanks Philipp, this is well explained, you're a good teacher.💪
@GN9K71
@GN9K71 Рік тому
Very nice video! I want to ask something, should I combine both MVC and MVVM tohether, for example: I have a viewmodel class that has a StateFlow reference and I need to update some UI state based on the values emited from the flow, so I want to extract the collect logic in a seraprate Controller class, and pass the viewmodel to controller, or better create a ViewModelGetter - interface that will be inherited from the Activity/Fragment, and will provide the viewmodel. Than the viewmodel will be obtained by ViewModelGetter interface?
@webdrizzled
@webdrizzled 11 місяців тому
Thanks bro. You are always helpful
@go_better
@go_better Рік тому
Thanks for the video. I will surely check your videos about the subjects, just at the moment I don't understand what are ViewModels, Fragments, Content providers and Broadcast recievers for. It feels like it's unnecessary concepts. I don't get their benefits. But once again, I'm going to do my research.
@mattgraves3709
@mattgraves3709 Рік тому
Kind of depends on a lot of factors, But if you build it correctly, each module and or component can use its own architecture, giving each team autonomy over their own architecture.
@prageeth4855
@prageeth4855 Рік тому
Woohoo 🎉 right on time!!
@CharfaouiYounes
@CharfaouiYounes Рік тому
I think that any developer should learn about all of this architecture and get comfortable with them so that if we work on a project that uses MVP (Legacy Project), we can work effectively. And when working on greenfield projects, we can use the appropriate and better architecture that suits the app well.
@mubaraknative
@mubaraknative 9 місяців тому
Your Subscriber
@haykmkrtchyan7093
@haykmkrtchyan7093 Рік тому
Philipp can u make a video about MVI using the data classes? I've done that using only sealed classes))
@yohankumar2441
@yohankumar2441 Рік тому
Hey i am making an app for image detection and store the data in a database. Few questions: 1)I am unable to get updated location from fusedlocationproviderAPI after calling updates regularly 2) which database is better NoSQL or SQL?
@vengateshm2122
@vengateshm2122 Рік тому
Thank You Phillip.
@moldovanpeter5123
@moldovanpeter5123 Рік тому
What about MVVM + ReduxKotlin for state management? I know that there some who are working this way on Diamond Client Projects.
@whitebl4ckk
@whitebl4ckk Рік тому
Great video as always
@PhilippLackner
@PhilippLackner Рік тому
For most projects it's too much imo. As I said at the end, learn about the core principles behind every architecture and then apply these principles and call it whatever you want
@DiegoNovati1
@DiegoNovati1 Рік тому
In the MVC architecture unfortunately the Controller knows the View (findById is just an example: it is used in the controller to change the View) and vice versa. It's the simples architecture to learn, but due tio the lack of separations on concerns it doesn't scale well in big projects.
@Berryss
@Berryss Рік тому
When I used mvc long time ago, the Controller never knew the view. Since the view changed using Callbacks from the controller. So the controller just knew an interface of the view, but not the actual view nor what views to change
@koczmen22
@koczmen22 Рік тому
@@Berryss That sounds like MVP. On both Android and iOS, MVC usually means no architecture at all. All stuff goes into the Activity or UIViewController.
@GN9K71
@GN9K71 Рік тому
Should Controller has to know anything about ViewModel?
@DiegoNovati1
@DiegoNovati1 Рік тому
@@GN9K71 MVC is Model/View/Controller so there is no ViewModel (ViewModel is in MVVM = Model/View/ViewModel)
@thiagosouza8931
@thiagosouza8931 Рік тому
Isn't MVI more than states and events? Like reducer, middleware, state machine and everything? What you said sounds just like MVVM 🤔
@siddhantsolanki3933
@siddhantsolanki3933 Рік тому
Hey Can you please make a video on how to read and understand an existing Android Huge Codebase?
@wojtekw9008
@wojtekw9008 Рік тому
Hey Philipp, Can you show difference's between MVI and MVVM on real code example? :) Btw i really love your content ❤️
@electromagneticbytes
@electromagneticbytes 10 місяців тому
R.I.P MVVM..etc. after arrival of Jetpack compose 😅
@lukaslechner
@lukaslechner Рік тому
08:35 Regarding race conditions with StateFlows & copy - If you perform the .copy() _within_ the update{} lambda, then it should be thread-safe, right?
@PedroBarbosaRoman
@PedroBarbosaRoman Рік тому
Yes, that would be my guess
@matthiaskerat351
@matthiaskerat351 Рік тому
Doesnt belong business logic to the model and not the viewmodel in mvvm per definition?
@Alchemist10241
@Alchemist10241 Рік тому
MVI plus a little bit MVVM is the best architecture. MVI fits very well with clean architecture.
@PhilippLackner
@PhilippLackner Рік тому
I like mvi for compose projects, but not much for xml
@rhen4610
@rhen4610 Рік тому
Heyy I have a question regarding viewmodel states, are data classes better than sealed classes when youre using them for your project's UI states? I noticed you switched from sealed class to data class on the note app and crypto app clean architecture video.
@PhilippLackner
@PhilippLackner Рік тому
They both have completely different purposes, I definitely did not use them for a whole screen's UI state
@mustafaammar551
@mustafaammar551 Рік тому
you are the best thank you
@nieqingls2931
@nieqingls2931 6 місяців тому
in compose + flow , how to control webview to reload ?
@saurabhyadav-sz9rx
@saurabhyadav-sz9rx Рік тому
In my firm, we use clean-MVVM architecture.
@bbk8550
@bbk8550 Рік тому
Are 'Android Architecture Component' and 'Clean Architecture' the same? If difference between let me know? Thank you...
@apoorvgupta2511
@apoorvgupta2511 Рік тому
That green light in the background sets the mood
@elqd91
@elqd91 Рік тому
you’ve said that in MVI, a screen has one state object. following this, how would you handle having multiple API calls on a single screen? let’s say you have 2 cards, one that shows the weather and one that shows user info. would you still use one state object and how would this look? or one for each card (API call)?
@ohefny
@ohefny Рік тому
So for me when it comes to single screen state it always mean that this states are related in some way inside the screen, so yes if you have two related parts in the screen that needs to be updated from 2 apis you'd probably combine them in a single state and whenever updates comes in you update the respected value in the state. But designing how the screen parts relate to each other makes things easier usually. So if multiple parts in the same screen are somehow indpendent those can ve separated to different fragments in the same screen with each fragment contining its state. If fragment spiliting is not an option you can also go with multiple viewmodels in the same fragment each one of them is related to specific portion. So it depends on the usecase actually.
@bhoomivaghasiya2794
@bhoomivaghasiya2794 5 місяців тому
Which Architectural pattern do you prefer for Large-scale Jetpack Compose apps? MVVM or MVI?
@sandeep_khariwal8137
@sandeep_khariwal8137 Рік тому
Should we learn all these model views or become good in one???
@shalomogbeche5680
@shalomogbeche5680 Рік тому
Very knowledgeable
@TGDEVABHAi
@TGDEVABHAi Місяць тому
Well explain
@breensrobert
@breensrobert Рік тому
well explained
@SiamakAshrafi
@SiamakAshrafi Рік тому
multi-module clean arch MVI is the best ... simple
@rontarrant
@rontarrant 6 днів тому
I've been experimenting with MIM (Monkey in the Middle), a looser take on MVVM in which the logic goes where it needs to be for clarity.
@CavernaMadridista-os9zn
@CavernaMadridista-os9zn 9 місяців тому
A video to watch 2 times before an interview
@HenriqueRocha
@HenriqueRocha Рік тому
Stopped watching when he said that Activities and Fragments are represented by the V in MV* patterns. I don't know why so many people get this wrong.
@boukarradhmoez99
@boukarradhmoez99 Рік тому
@Philipp so what is the difference between these architectures and the clean architecture ?
@Frozen_Priest
@Frozen_Priest Рік тому
Clean architecture is for a whole application, mvx are presentation layer only. Your app can be clean while using any of them
@FemiOkedey
@FemiOkedey Рік тому
I prefer to use MVI for personal projects because it's easier to understand and explain especially with Compose. But I prefer MVVM professionally.
@sebastianseno9285
@sebastianseno9285 Рік тому
MVVM is best for me
@yangyun6221
@yangyun6221 Рік тому
MVC: controller can updates View!
@theophilus494
@theophilus494 Рік тому
thank you Phillip. i just want to ask how do schedule your studying time.. like how do you allocate time to learning.. i use MVVM android dev since it's google's recommendation
@PhilippLackner
@PhilippLackner Рік тому
I learn most of my stuff either by creating videos or by working on actual projects and researching my issues. Both belongs to my work
@alanesaugarciagutierrez6025
@alanesaugarciagutierrez6025 Рік тому
Hi Phillip what about VIPER?
@argahutama
@argahutama Рік тому
In my opinion, VIPER is the next level of MVP (Clean arch version of MVP). I think that's not common in Android. MVVM and MVI are the perfect arch pattern for Android atm.
@k40ol
@k40ol 10 місяців тому
Good video! Would prefer more: - Diagrams, showing these in action. - Less talking, more whiteboard / abstract concept demonstration.
@PhilippLackner
@PhilippLackner 10 місяців тому
Thanks for the feedback!
@baljeetsandhu8718
@baljeetsandhu8718 Рік тому
Hehe morning dose of Android... Thanks
@CavernaMadridista-os9zn
@CavernaMadridista-os9zn 9 місяців тому
even MBS got a shout out jajajajaja
@freedomchuks
@freedomchuks Рік тому
Update from the state flow is thread safe hence you wouldn't get the race condition
@PhilippLackner
@PhilippLackner Рік тому
Not, if you update it using copy() without flow.update
@freedomchuks
@freedomchuks Рік тому
@@PhilippLackner we are saying the same thing I hadn't gotten the part when you talked about the update extension so I wrote the comments
@kyleolson8977
@kyleolson8977 Рік тому
I cannot agree with the "More Vulnerable to Race Conditions", at least for the reasons you're saying. If your data in MVVM or in MVI could be touched on another thread while you are touching it, you're doing something wrong. Any data which could be touched by multiple threads must be protected. "If you don't practice thread safety it's not thread safe" is not a bug if the thread safety is fairly straightforward as it is here. At best, it's "less likely for mistake to matter". It's possible or even likely the copy is so quick compared to UI operations using data that if you are dealing with unprotected data in both models the MVVM ui is more likely to create an inconsistent state. This would be much more of a literal race condition.
@RiccardoGabellone
@RiccardoGabellone Рік тому
💪🏻
@alonshlider4881
@alonshlider4881 Рік тому
MVI can be implemented with a sealed class representing the UI state which prevents the race condition you were talking about because you set the value to a new one and not copying the old one
@erfansn869
@erfansn869 Рік тому
MVI + MVVM + CLEAN = Android recommended architecture
@parveshkhatri1027
@parveshkhatri1027 Рік тому
I'm learning android dev for a year and I don't like it. First, they don't give good documentation, I mean I can't go there and code something from reading there like creating a notification. Second, thay change things very quickly, codes from year-old tutorials can't be used today without modifications, which also they don't document that well.
@yudelmartinez29
@yudelmartinez29 8 місяців тому
the struggle is real
@user-rr2db1vu3z
@user-rr2db1vu3z Рік тому
👍
@DiegoNovati1
@DiegoNovati1 Рік тому
Lot of mistakes in this video. the MVVM is not about states but it's about visibility and accessibility. In the MVVM the View knows and uses only the ViewModel, and the view models knows nothing about the View, infact it raises events that can be managed by any View listening for the events; the ViewModels knows and uses only the Model, but Model knows nothing about ViewModel because it notifies changes raising events for any ViewModel listening for the events. MVVM was created by John Gossman in 2005, and it's not related to Android at all. Another details: if you are using Compose, I suggest you to have 1 single state in the ViewModel (implemented as a read only Data Class) and each time you need to update it, change all the properies you need and then notifiy the change: the View will recompose itself in one go instead of recomposing itself by the number of properties you are changing.
@PhilippLackner
@PhilippLackner Рік тому
Didn't I say exactly that?
@yangyun6221
@yangyun6221 Рік тому
If MVVM, then what is Acitvity/Fragment's role in this architecture. I have to say Android is a mess.
@favour2871
@favour2871 Рік тому
goat
@John-qt6qk
@John-qt6qk Рік тому
MVVM ALL THE WAY
@user-kh6rp6yx1j
@user-kh6rp6yx1j 24 дні тому
Hello
@mouhamadbourouba5382
@mouhamadbourouba5382 Рік тому
MVI makes my life easier so I use it 🙂
@misiu9049
@misiu9049 Рік тому
There is no the best architecture. Architecture is project specific !
@nikhilsingh-zs1ul
@nikhilsingh-zs1ul Рік тому
MVVM
@omarredani5580
@omarredani5580 Рік тому
It seems like you are taking Gym really seriously hhh
@mymobile550
@mymobile550 Рік тому
😄
@UCdsDlBCBCKMiUUvc8zBWOVQ
@UCdsDlBCBCKMiUUvc8zBWOVQ Рік тому
.
@patrickrodriguez4683
@patrickrodriguez4683 Рік тому
MVVM is best for me
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Переглядів 23 тис.
Make Your Code Clean With the SOLID Principles
18:24
Philipp Lackner
Переглядів 93 тис.
Teenagers Show Kindness by Repairing Grandmother's Old Fence #shorts
00:37
Fabiosa Best Lifehacks
Переглядів 34 млн
Мама забыла взять трубочку для колы
00:25
Даша Боровик
Переглядів 528 тис.
Which Software Architecture Should You Use: MVC, MVP, or MVVM?
24:27
ArjanCodes
Переглядів 104 тис.
You might not need useEffect() ...
21:45
Academind
Переглядів 133 тис.
The Ultimate guide to MVI in Android
29:52
Land of coding
Переглядів 7 тис.
Programming vs Coding - What's the difference?
5:59
Aaron Jack
Переглядів 1,9 млн
The FULL Beginner to Pro Roadmap for Android Development in 2023
10:47
Philipp Lackner
Переглядів 223 тис.
ChatGPT’s Amazing New Model Feels Human (and it's Free)
25:02
Matt Wolfe
Переглядів 61 тис.
Teenagers Show Kindness by Repairing Grandmother's Old Fence #shorts
00:37
Fabiosa Best Lifehacks
Переглядів 34 млн