What Is the Best Architecture for Android Apps?

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

  • @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

  • @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 🙏 ❤️

  • @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

    Жыл бұрын

    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 !

  • @ClowneryCity
    @ClowneryCity7 ай бұрын

    Thanks Philipp, this is well explained, you're a good teacher.💪

  • @kenali4612
    @kenali4612 Жыл бұрын

    Been waiting on this one !!

  • @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 :)

  • @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.

  • @webdrizzled
    @webdrizzled Жыл бұрын

    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.

  • @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?

  • @vengateshm2122
    @vengateshm2122 Жыл бұрын

    Thank You Phillip.

  • @prageeth4855
    @prageeth4855 Жыл бұрын

    Woohoo 🎉 right on time!!

  • @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

  • @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.

  • @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

    11 ай бұрын

    Your Subscriber

  • @haykmkrtchyan7093
    @haykmkrtchyan7093 Жыл бұрын

    Philipp can u make a video about MVI using the data classes? I've done that using only sealed classes))

  • @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

  • @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?

  • @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

  • @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)

  • @siddhantsolanki3933
    @siddhantsolanki3933 Жыл бұрын

    Hey Can you please make a video on how to read and understand an existing Android Huge Codebase?

  • @matthiaskerat351
    @matthiaskerat351 Жыл бұрын

    Doesnt belong business logic to the model and not the viewmodel in mvvm per definition?

  • @apoorvgupta2511
    @apoorvgupta2511 Жыл бұрын

    That green light in the background sets the mood

  • @thiagosouza8931
    @thiagosouza8931 Жыл бұрын

    Isn't MVI more than states and events? Like reducer, middleware, state machine and everything? What you said sounds just like MVVM 🤔

  • @shalomogbeche5680
    @shalomogbeche5680 Жыл бұрын

    Very knowledgeable

  • @wojtekw9008
    @wojtekw9008 Жыл бұрын

    Hey Philipp, Can you show difference's between MVI and MVVM on real code example? :) Btw i really love your content ❤️

  • @TGDEVABHAi
    @TGDEVABHAi3 ай бұрын

    Well explain

  • @mustafaammar551
    @mustafaammar551 Жыл бұрын

    you are the best thank you

  • @breensrobert
    @breensrobert Жыл бұрын

    well explained

  • @saurabhyadav-sz9rx
    @saurabhyadav-sz9rx Жыл бұрын

    In my firm, we use clean-MVVM architecture.

  • @electromagneticbytes
    @electromagneticbytes11 ай бұрын

    R.I.P MVVM..etc. after arrival of Jetpack compose 😅

  • @moldovanpeter5123
    @moldovanpeter5123 Жыл бұрын

    What about MVVM + ReduxKotlin for state management? I know that there some who are working this way on Diamond Client Projects.

  • @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.

  • @bbk8550
    @bbk8550 Жыл бұрын

    Are 'Android Architecture Component' and 'Clean Architecture' the same? If difference between let me know? Thank you...

  • @bhoomivaghasiya2794
    @bhoomivaghasiya27946 ай бұрын

    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???

  • @rontarrant
    @rontarrantАй бұрын

    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.

  • @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

  • @nieqingls2931
    @nieqingls29317 ай бұрын

    in compose + flow , how to control webview to reload ?

  • @CavernaMadridista-os9zn
    @CavernaMadridista-os9zn11 ай бұрын

    A video to watch 2 times before an interview

  • @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

  • @SiamakAshrafi
    @SiamakAshrafi Жыл бұрын

    multi-module clean arch MVI is the best ... simple

  • @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

  • @baljeetsandhu8718
    @baljeetsandhu8718 Жыл бұрын

    Hehe morning dose of Android... Thanks

  • @k40ol
    @k40ol Жыл бұрын

    Good video! Would prefer more: - Diagrams, showing these in action. - Less talking, more whiteboard / abstract concept demonstration.

  • @PhilippLackner

    @PhilippLackner

    Жыл бұрын

    Thanks for the feedback!

  • @yangyun6221
    @yangyun6221 Жыл бұрын

    MVC: controller can updates View!

  • @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.

  • @RiccardoGabellone
    @RiccardoGabellone Жыл бұрын

    💪🏻

  • @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

  • @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

  • @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.

  • @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.

  • @erfansn869
    @erfansn869 Жыл бұрын

    MVI + MVVM + CLEAN = Android recommended architecture

  • @user-rr2db1vu3z
    @user-rr2db1vu3z Жыл бұрын

    👍

  • @favour2871
    @favour2871 Жыл бұрын

    goat

  • @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

    9 ай бұрын

    the struggle is real

  • @user-kh6rp6yx1j
    @user-kh6rp6yx1j2 ай бұрын

    Hello

  • @CavernaMadridista-os9zn
    @CavernaMadridista-os9zn10 ай бұрын

    even MBS got a shout out jajajajaja

  • @nikhilsingh-zs1ul
    @nikhilsingh-zs1ul Жыл бұрын

    MVVM

  • @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?

  • @mymobile550
    @mymobile550 Жыл бұрын

    😄

  • @John-qt6qk
    @John-qt6qk Жыл бұрын

    MVVM ALL THE WAY

  • @yangyun6221
    @yangyun6221 Жыл бұрын

    If MVVM, then what is Acitvity/Fragment's role in this architecture. I have to say Android is a mess.

  • @mouhamadbourouba5382
    @mouhamadbourouba5382 Жыл бұрын

    MVI makes my life easier so I use it 🙂

  • @omarredani5580
    @omarredani5580 Жыл бұрын

    It seems like you are taking Gym really seriously hhh

  • @UCdsDlBCBCKMiUUvc8zBWOVQ
    @UCdsDlBCBCKMiUUvc8zBWOVQ Жыл бұрын

    .

  • @misiu9049
    @misiu9049 Жыл бұрын

    There is no the best architecture. Architecture is project specific !

  • @patrickrodriguez4683
    @patrickrodriguez4683 Жыл бұрын

    MVVM is best for me