No video

What Is the Best Architecture for Android Apps?

  Рет қаралды 56,870

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/...
💻 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/...
Subscribe to my FREE newsletter for regular Android, Kotlin & Architecture advice!
pl-coding.com/...
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/phi...
You like my free content? Here you can buy me a coffee:
www.buymeacoff...

Пікірлер: 99
@haykmkrtchyan7093
@haykmkrtchyan7093 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
Thanks so much 🙏 ❤️
@shaiquekhan1185
@shaiquekhan1185 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
@@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 2 жыл бұрын
@@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 2 жыл бұрын
@@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
@TheBlackManMythLegend
@TheBlackManMythLegend 2 жыл бұрын
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 2 жыл бұрын
Thanks for the kind words! Appreciated :)
@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 !
@IronGuy21
@IronGuy21 2 жыл бұрын
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.
@DiegoNovati1
@DiegoNovati1 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
@@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 2 жыл бұрын
Should Controller has to know anything about ViewModel?
@DiegoNovati1
@DiegoNovati1 2 жыл бұрын
@@GN9K71 MVC is Model/View/Controller so there is no ViewModel (ViewModel is in MVVM = Model/View/ViewModel)
@wojtekw9008
@wojtekw9008 2 жыл бұрын
Hey Philipp, Can you show difference's between MVI and MVVM on real code example? :) Btw i really love your content ❤️
@bhoomivaghasiya2794
@bhoomivaghasiya2794 8 ай бұрын
Which Architectural pattern do you prefer for Large-scale Jetpack Compose apps? MVVM or MVI?
@CharfaouiYounes
@CharfaouiYounes 2 жыл бұрын
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 Жыл бұрын
Your Subscriber
@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.
@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.
@thiagosouza8931
@thiagosouza8931 2 жыл бұрын
Isn't MVI more than states and events? Like reducer, middleware, state machine and everything? What you said sounds just like MVVM 🤔
@lukaslechner
@lukaslechner 2 жыл бұрын
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 2 жыл бұрын
Yes, that would be my guess
@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.
@Alchemist10241
@Alchemist10241 2 жыл бұрын
MVI plus a little bit MVVM is the best architecture. MVI fits very well with clean architecture.
@PhilippLackner
@PhilippLackner 2 жыл бұрын
I like mvi for compose projects, but not much for xml
@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.
@rontarrant
@rontarrant 4 ай бұрын
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.
@GN9K71
@GN9K71 2 жыл бұрын
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?
@mattgraves3709
@mattgraves3709 2 жыл бұрын
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.
@electromagneticbytes
@electromagneticbytes Жыл бұрын
R.I.P MVVM..etc. after arrival of Jetpack compose 😅
@ClowneryCity
@ClowneryCity 9 ай бұрын
Thanks Philipp, this is well explained, you're a good teacher.💪
@matthiaskerat351
@matthiaskerat351 2 жыл бұрын
Doesnt belong business logic to the model and not the viewmodel in mvvm per definition?
@kenali4612
@kenali4612 2 жыл бұрын
Been waiting on this one !!
@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!
@webdrizzled
@webdrizzled Жыл бұрын
Thanks bro. You are always helpful
@apoorvgupta2511
@apoorvgupta2511 2 жыл бұрын
That green light in the background sets the mood
@haykmkrtchyan7093
@haykmkrtchyan7093 2 жыл бұрын
Philipp can u make a video about MVI using the data classes? I've done that using only sealed classes))
@whitebl4ckk
@whitebl4ckk 2 жыл бұрын
Great video as always
@PhilippLackner
@PhilippLackner 2 жыл бұрын
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
@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.
@bbk8550
@bbk8550 2 жыл бұрын
Are 'Android Architecture Component' and 'Clean Architecture' the same? If difference between let me know? Thank you...
@boukarradhmoez99
@boukarradhmoez99 2 жыл бұрын
@Philipp so what is the difference between these architectures and the clean architecture ?
@Frozen_Priest
@Frozen_Priest 2 жыл бұрын
Clean architecture is for a whole application, mvx are presentation layer only. Your app can be clean while using any of them
@saurabhyadav-sz9rx
@saurabhyadav-sz9rx 2 жыл бұрын
In my firm, we use clean-MVVM architecture.
@prageeth4855
@prageeth4855 2 жыл бұрын
Woohoo 🎉 right on time!!
@alanesaugarciagutierrez6025
@alanesaugarciagutierrez6025 2 жыл бұрын
Hi Phillip what about VIPER?
@argahutama
@argahutama 2 жыл бұрын
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.
@siddhantsolanki3933
@siddhantsolanki3933 2 жыл бұрын
Hey Can you please make a video on how to read and understand an existing Android Huge Codebase?
@sandeep_khariwal8137
@sandeep_khariwal8137 2 жыл бұрын
Should we learn all these model views or become good in one???
@yohankumar2441
@yohankumar2441 2 жыл бұрын
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?
@yangyun6221
@yangyun6221 Жыл бұрын
MVC: controller can updates View!
@elqd91
@elqd91 2 жыл бұрын
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 2 жыл бұрын
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.
@vengateshm2122
@vengateshm2122 2 жыл бұрын
Thank You Phillip.
@sebastianseno9285
@sebastianseno9285 2 жыл бұрын
MVVM is best for me
@moldovanpeter5123
@moldovanpeter5123 2 жыл бұрын
What about MVVM + ReduxKotlin for state management? I know that there some who are working this way on Diamond Client Projects.
@nieqingls2931
@nieqingls2931 10 ай бұрын
in compose + flow , how to control webview to reload ?
@rhen4610
@rhen4610 2 жыл бұрын
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 2 жыл бұрын
They both have completely different purposes, I definitely did not use them for a whole screen's UI state
@TGDEVABHAi
@TGDEVABHAi 5 ай бұрын
Well explain
@CavernaMadridista-os9zn
@CavernaMadridista-os9zn Жыл бұрын
A video to watch 2 times before an interview
@SiamakAshrafi
@SiamakAshrafi Жыл бұрын
multi-module clean arch MVI is the best ... simple
@theophilus494
@theophilus494 2 жыл бұрын
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 2 жыл бұрын
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
@freedomchuks
@freedomchuks 2 жыл бұрын
Update from the state flow is thread safe hence you wouldn't get the race condition
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Not, if you update it using copy() without flow.update
@freedomchuks
@freedomchuks 2 жыл бұрын
@@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
@mustafaammar551
@mustafaammar551 2 жыл бұрын
you are the best thank you
@DiegoNovati1
@DiegoNovati1 2 жыл бұрын
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 2 жыл бұрын
Didn't I say exactly that?
@shalomogbeche5680
@shalomogbeche5680 2 жыл бұрын
Very knowledgeable
@erfansn869
@erfansn869 2 жыл бұрын
MVI + MVVM + CLEAN = Android recommended architecture
@breensrobert
@breensrobert 2 жыл бұрын
well explained
@parveshkhatri1027
@parveshkhatri1027 2 жыл бұрын
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 11 ай бұрын
the struggle is real
@alonshlider4881
@alonshlider4881 2 жыл бұрын
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
@baljeetsandhu8718
@baljeetsandhu8718 2 жыл бұрын
Hehe morning dose of Android... Thanks
@yangyun6221
@yangyun6221 Жыл бұрын
If MVVM, then what is Acitvity/Fragment's role in this architecture. I have to say Android is a mess.
@misiu9049
@misiu9049 Жыл бұрын
There is no the best architecture. Architecture is project specific !
@user-kh6rp6yx1j
@user-kh6rp6yx1j 4 ай бұрын
Hello
@RiccardoGabellone
@RiccardoGabellone 2 жыл бұрын
💪🏻
@John-qt6qk
@John-qt6qk 2 жыл бұрын
MVVM ALL THE WAY
@CavernaMadridista-os9zn
@CavernaMadridista-os9zn Жыл бұрын
even MBS got a shout out jajajajaja
@mouhamadbourouba5382
@mouhamadbourouba5382 2 жыл бұрын
MVI makes my life easier so I use it 🙂
@user-rr2db1vu3z
@user-rr2db1vu3z 2 жыл бұрын
👍
@nikhilsingh-zs1ul
@nikhilsingh-zs1ul 2 жыл бұрын
MVVM
@favour2871
@favour2871 2 жыл бұрын
goat
@omarredani5580
@omarredani5580 2 жыл бұрын
It seems like you are taking Gym really seriously hhh
@mymobile550
@mymobile550 2 жыл бұрын
😄
@xalikv
@xalikv 2 жыл бұрын
.
@patrickrodriguez4683
@patrickrodriguez4683 2 жыл бұрын
MVVM is best for me
MVI в Android на практике
19:20
Тимофей Коваленко
Рет қаралды 15 М.
5 Fatal Coroutine Mistakes Nobody Tells You About
18:15
Philipp Lackner
Рет қаралды 87 М.
나랑 아빠가 아이스크림 먹을 때
00:15
진영민yeongmin
Рет қаралды 14 МЛН
Zombie Boy Saved My Life 💚
00:29
Alan Chikin Chow
Рет қаралды 34 МЛН
Oh No! My Doll Fell In The Dirt🤧💩
00:17
ToolTastic
Рет қаралды 13 МЛН
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Рет қаралды 40 М.
Make Your Code Clean With the SOLID Principles
18:24
Philipp Lackner
Рет қаралды 98 М.
ViewModels & Configuration Changes - Android Basics 2023
18:46
Philipp Lackner
Рет қаралды 116 М.
Everything You NEED to Know About Client Architecture Patterns
5:51