6 Design Patterns Every Android Developer Must Know

  Рет қаралды 84,616

Philipp Lackner

Philipp Lackner

Күн бұрын

Пікірлер: 126
@LinggarMaretvaCendani
@LinggarMaretvaCendani 3 жыл бұрын
0:49 Singleton 2:46 Factory 5:04 Builder 8:31 Facade 9:44 Dependency Injection 12:30 Adapter
@shalatan
@shalatan 3 жыл бұрын
Can you create a video for something like 'Best practices for big apps or advanced apps' to keep them easily readable and updatable with time ?? 🤔🤔
@PhilippLackner
@PhilippLackner 3 жыл бұрын
cool idea, will think about it
@bboydarknesz
@bboydarknesz 3 жыл бұрын
@@PhilippLackner clean architecture. wow, cant wait! Hope it also support for REST API, login, token, handle expired token
@fireshipai
@fireshipai 2 жыл бұрын
I'm looking exactly for the same thing. Still can't find a good video/series for advanced practices for developing big and scalable apps
@andyli619
@andyli619 Жыл бұрын
good idea
@SebastianHasch
@SebastianHasch 4 ай бұрын
The two most important things are to 1. Have a plan on what you want to do beforehand so you can 2. Organise your code in a way that makes sense and is easily extendible.
@lifeOfCharlesMaina
@lifeOfCharlesMaina 3 жыл бұрын
You are the best Android and Kotlin teacher I have encountered!! Thank you Phillip...you are literally saving careers out here💯💯💯
@newbiegameplayy
@newbiegameplayy 3 жыл бұрын
Very useful information... If you have a time please make a series for cracking clean Architecture for Android Development. It will be great series for all of us 🙏🏻
@mustaqode_6617
@mustaqode_6617 3 жыл бұрын
Might look like just another topic. But this is really one of those topics which most developers have no idea about even though they use all these all the time. From my personal experience, this video will save u from embarrassment while attending android interviews. Thanks phlip.
@DARKcarlos1
@DARKcarlos1 3 жыл бұрын
Dammnnnn phillip, right now I’m doing a test app because I’m applying for an android developer job… and that builder pattern just saved me the day. You don’t know how many hours I was trying to do something in an adapter and this builder pattern was the perfect way to do that. Thank you very much for this video, It came in divine timing
@matt-g-recovers
@matt-g-recovers 3 жыл бұрын
Excellent video, I learned quite a bit about both the patterns in kotlin and gained insight into better ways. Thanks Phillipp! I learned these all in Java many years ago... it's so refreshing to see the idiomatic Kotlin versions as well as gain some further insight into each.
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Glad you enjoyed it
@ErikBongers
@ErikBongers 6 ай бұрын
Having a constructor with default values isn't the best example of a Builder pattern. A typical Builder should force you to, for example, provide arguments or dependencies in a specific order or a user defined order, or perhaps dissallow a dependency if a previously specified dependency was of a restrictive kind or allow an argument to be given more than once. In other words, a Builder allows you to restrict argument requirements or give more flexible arguments or a combination of both. The Modifier is the best example of this. Don't be fooled by it not having this final build() call.
@voidpointer398
@voidpointer398 3 жыл бұрын
As always, unique content. Thanks man ❤
@PhilippLackner
@PhilippLackner 3 жыл бұрын
My pleasure!
@vengateshm2122
@vengateshm2122 3 жыл бұрын
Excellent. Interview prep material. Decorator - Modifying an object during runtime. Eg: Recycler view item decorator
@vengateshm2122
@vengateshm2122 3 жыл бұрын
Feeling overwhelmed when getting a love for my comment from the creator who is 1000s of miles apart. Thanks to the technology.
@vibovitold
@vibovitold Ай бұрын
Decorator does not "modify" an object. It typically wraps over an object, usually enhancing its behavior. RecyclerView's item decorator has got nothing to do with the Decorator pattern, other than its name. It's only "decorating" in visual everyday sense, not in the structural design pattern sense. The Decorator pattern revolves around composition and delegation.
@righteouscoder
@righteouscoder 3 жыл бұрын
So a note about the Kotlin way of doing builder, it isn't actually the builder pattern, b/c it doesn't hide the concrete implementation details from the end user. A proper builder pattern can have constructor parameters of the built class change name/order/etc. and not be visible to the end user. However, in the kotlin methodology, you are directly exposing the constructor to the end user. Even with parameter naming, you have an easier chance of making compile breaking changes if you do this vs hiding the details inside the builder.
@vibovitold
@vibovitold Жыл бұрын
Builder pattern doesn't necessarily have to hide, alias, abstract or simplify the object's API. It sure CAN, and it may be pretty useful... but that' becomes more of a Builder + Factory / Facade combo. The main point of a Builder is just that it allows to construct an object step by step (which includes the possibility of passing a Builder elswhere, so that some other code can finish what we started). Just because some Builder does "naively" reflect the constructor signature 1-to-1 doesn't mean it's not a "proper Builder patten".
@new_kind_of
@new_kind_of Жыл бұрын
Simplied and to the point. Good work Philipp 👏
@akeeaggarwal8087
@akeeaggarwal8087 3 жыл бұрын
You have made them super easy for us to understand. Thanks man.👍
@jaygitonga2026
@jaygitonga2026 3 жыл бұрын
As always great videos Phillip! Do a tutorial on clean architecture or mvi
@ibrahimkhalilshakir2414
@ibrahimkhalilshakir2414 3 жыл бұрын
Great job. Please make an e-commerce or Video calling app tutorial 😊
@iliass1
@iliass1 3 жыл бұрын
I like the way you teach, so cool. I learnt a lot from you. thanks bro
@PhilippLackner
@PhilippLackner 3 жыл бұрын
you're welcome
@FaroukSonic
@FaroukSonic 3 жыл бұрын
Thank you so much bro! I recently discovered your channel and it's super helpful! Great content!
@ronyaburaihan
@ronyaburaihan 3 жыл бұрын
Can you create a video for webrtc for Android?
@mare10rooney
@mare10rooney 3 жыл бұрын
Another great video Philipp! Thanks for handling some of the advanced topics...
@PhilippLackner
@PhilippLackner 3 жыл бұрын
thanks!
@mkc0321
@mkc0321 2 жыл бұрын
the best time i spend on youtube is seeing your videos
@devgabriel6898
@devgabriel6898 8 ай бұрын
Saw this video (AMAZING) 2 years ago and now Android has also lift us of that horrible recycler views adapters thanks to Compose xD
@Coldalecs
@Coldalecs 2 жыл бұрын
Loved it! I like how easy is to understand from what you explain.
@InaAgapito
@InaAgapito 3 жыл бұрын
It was really helpful! I'm learning to develop for android but this topic isn't so talked in many courses or even when happen is to much superficial, so could you say when should a beginner student as me start to study it?
@jam4l
@jam4l 2 жыл бұрын
A great video as always, Ty.
@ghasemshirdel6933
@ghasemshirdel6933 3 жыл бұрын
Thanks Philipp , I think some other patterns like Object Pool, Flyweight, Decorator, Observer, Strategy and Proxy has useful in a project
@unaisulhadi9102
@unaisulhadi9102 3 жыл бұрын
Excellent video Phil!!
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Glad you enjoyed it
@saumilpatel2480
@saumilpatel2480 3 жыл бұрын
Very useful Phillip. Great content as always 👏👏👏
@asifmehmood9307
@asifmehmood9307 3 жыл бұрын
great information it's help full for me great effort bro
@techmarinar
@techmarinar 3 жыл бұрын
Thanx man this was very very helpful 😊
@josephmolina5477
@josephmolina5477 3 жыл бұрын
Please continue to make more videos on these topics !
@Sc2MooDy
@Sc2MooDy 3 жыл бұрын
Thank you for this video, please keep making those kind of videos :D. I suggest one about gradle
@SurajKumar-vi3ll
@SurajKumar-vi3ll 2 жыл бұрын
can you create a video for "keyboard productive hacks in android sudio"? i know few of them I like: 1. ctrl + Alt + Shift + up/down to go the edited location in the same page 2. double shift to search anything.
@krhijaerhtuirthsirthu164
@krhijaerhtuirthsirthu164 2 жыл бұрын
Podrias explicarme mas detalladamente como implementar el patron Factory en mi proyecto porfavor ?
@pradeep9222
@pradeep9222 3 жыл бұрын
it's awesome, thank you so much
@samdroid37
@samdroid37 2 жыл бұрын
please make a video over page object model pattern for testing with kotlin!
@alirohmansyah7914
@alirohmansyah7914 3 жыл бұрын
thanks philipp. btw have you ever made a video about rxjava ?
@devgabriel6898
@devgabriel6898 2 жыл бұрын
Is Observer one of them and very used in Android too? Or im wrong?
@shreyashchoudhary2637
@shreyashchoudhary2637 3 жыл бұрын
Yeah! 2 of 6 I don't even heard before ❤️
@FatLlama31882
@FatLlama31882 2 жыл бұрын
I'd like to express to some of the less experienced viewers why one of your comments on builder patterns in Kotlin is a bit inaccurate. Not wrong though. I'm referring to using named args to simulate a builder pattern. While this can be very useful and is likely a good idea in some builders. The builder pattern is used to create complex objects. The point of it is that you don't always have everything you need at the time you call a constructor. With your way the developer has to make sure all required dependencies are before calling the constructor as the object is meant to be immutable (or very close to it) once created. This is why a builder object is made. The values can change and be set after the builder objects creation. This builder can be passed around to configuration classes. That or the creation of a dependency can happen, then the builder set function is called, then you create the next dependency and so on. One other benefit to the builder object is that it can throw an error for objects that aren't configured correctly. Usually the Builder constructor has the minimum requirements for the .build() function to work but this isn't always true. The androidx biometric library has a good example of the builder throwing an exception for improperly configured builders. If you try to set the prompt cancellation button text while also trying to set device credential as an option for the prompt then these two states can't exist at the same time as they occupy the same space on the biometric prompt. So an error is thrown. In my eyes this is poor design so that leads into my next paragraph. Where I agree with your approach is that the builder to me (purely opinion at this point) is a bit of an anti pattern. It lets you get away with bad design. If you can't create the dependencies before calling the constructor then maybe you need to refactor some stuff or maybe the object is a bit too complex and doing too much. As with everything in programming it is knowing your requirements and which tool (pattern in this case) to get a job done. There is no one solution and that is why I am not saying you are wrong for your Kotlin approach to builders. Just wanted newer devs to understand the use of the Builder object.
@vibovitold
@vibovitold Жыл бұрын
"One other benefit to the builder object is that it can throw an error for objects that aren't configured correctly." The same can be done by the object's constructor (or its factory function). Your other points are valid, but this one feels unconvincing to me.
@FatLlama31882
@FatLlama31882 Жыл бұрын
Yeah just re read my comment and I may have missed some context or something out as I agree that didn't really make much sense.
@rba6486
@rba6486 2 жыл бұрын
Hey Philipp, i've got a question regarding the patterns introduced by you. You start with singletons. For what I know, they are considered being an anti-pattern, which shouldn't be used due to tight coupling, etc. So, why using them at all?
@vibovitold
@vibovitold Жыл бұрын
I don't know what Philipp thinks about it, but here's my take on it. Singletons aren't always bad, that's a generalization. The main problems with singletons are: 1. Singletons tend to obfuscate dependencies. If a class Frobnicator is a singleton, it can be accessed from everywhere, which leads to poor code design, and you can't dictate by code design which classes are legitimate and intended users of Frobnicator. You don't have to worry about propagating it, which makes things easy in the short run, but may lead to sloppy and lazy code design. (Case in point: event buses, which were a popular Android anti-pattern for quite a while). 2. Singletons can be used to hold global state, and global state is usually a bad idea, for reasons related to #1. It also gets in the way of testability, since it's hard to replace a singleton for the sake of unit testing. You either have to resort to tricks such as mocking statics, or your tests have to reset the state of the singleton... and every time you forget about resetting, there goes the isolation (because the tests are no longer independent - one test can contaminate the state of the singleton, with an impact on subsequent tests). However: a) Singletons can be stateless, and this resolves the problem of global state. Sometimes stateless singletons are just redundant in Kotiln (no need for a CollectionUtils singleton, just define extension functions, since Kotlin supports standalone functiions). But eg. android.util.Log is a singleton, and it's generally not a big deal. b) It's preferable to define a singleton via your DI framework. They typically support singletons (@Singleton annotation in Dagger 2, singleton in Koin etc.). So you can have the framework guarantee that some class will be functionally a singleton - there will only ever be one instance of it - but you don't define it as an object, you just define it as a class. This makes it easy to subtitute it in tests, and to keep the dependencies transparent, mitigating the main problems associated with the use of singletons. So the problems have solutions, and while caution is advised, there is still proper use for singletons. The default mindset, however, should be "why yes?" instead of "why not?", whenever you are tempted to define something as a singleton.
@abhishekauti164
@abhishekauti164 3 жыл бұрын
Hey man it was really helpful
@alix3665
@alix3665 9 ай бұрын
GOD I Needed this video... FUCKIN LOVE YOU PHILIP❤❤
@ZaidZakir
@ZaidZakir 3 жыл бұрын
Great video ☺️
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thank you!! 😊
@JavierMartinez-kc2ps
@JavierMartinez-kc2ps 3 жыл бұрын
Great video!! Can you create a video about how we can organize a Gradle in a big app o maybe how use tasks. For example a Jacoco task to use in sonar
@theophilus494
@theophilus494 3 жыл бұрын
Great and lovely video... Kindly make tutorials on dagger. Thank you boss..
@subindsuresh4897
@subindsuresh4897 3 жыл бұрын
Thank you bro.
@mustaqode_6617
@mustaqode_6617 3 жыл бұрын
Perfect as always.
@Alchemist10241
@Alchemist10241 3 жыл бұрын
If singleton pattern is just an object in kotlin, why we create room database class singleton like java singletons (using @syncronized and private Instance)?
@Akira-sh7ts
@Akira-sh7ts 3 жыл бұрын
stupid question In frontend web dev why we need to learn design patterns because I am learning react and never saw this things....
@alextl97
@alextl97 3 жыл бұрын
Hey Philipp can you make a video about data structures you use the most in Kotlin and in what cases, like for example Hashmaps. Great video like always btw.
@sunildhakar078
@sunildhakar078 3 жыл бұрын
Hi, Philipp Great job. can you create a video on app performance for big apps?
@shoaibkhalid6156
@shoaibkhalid6156 3 жыл бұрын
Amazing. Do you have any discord channels?
@darksoul2474
@darksoul2474 6 ай бұрын
Make video for Android Google interviews
@sat_talk
@sat_talk 3 жыл бұрын
Great video.. Pl. make a project on Forum App or Polling App
@javacore-qk9kd
@javacore-qk9kd 10 ай бұрын
you are the man of God💖💖💖💖
@muhammadmuzammil2575
@muhammadmuzammil2575 3 жыл бұрын
Can you please show some examples of adapter pattern other than recycler view adapter. Literally i couldn't adapt the adapter pattern :P
@vibovitold
@vibovitold Жыл бұрын
Eg. every mapper converting an object from - say - an API response to an object your business logic uses. (Because you don't want your business logic to get updated everywhere every time a json structure changes; that's not good separation of concerns). So you may have a type like UserResponse (which reflects how user data is represented in the json returned by some API endpoint, and is used for deserialization of these responses), but then you've got an Adapter which translates those UserResponse objects into User classes that your app actually deals with. Thanks to this, if a structure of UserResponse ever changes (eg. they've renamed a field, or the "badges" collection is now nested under "attributes" etc., whatever), the impact of that change is contained. You're just updating your Adapter, but all your business logic can remain unchanged. I'm aware that your question is 2 years old, but someone else may be reading it just the same, possibly wondering the same thing.
@yelamanmyrzahanov9883
@yelamanmyrzahanov9883 3 жыл бұрын
As always, unique content and easy to watch Can you please make video about anti pattens in Android?
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Cool idea 👍
@beypazariofficial
@beypazariofficial Жыл бұрын
facade is like mcdonalds i dont want to see how the bigmac is made
@skillz7
@skillz7 3 жыл бұрын
Hello sir , your doing great 🔥 , I will start android dev , from next week , can tell start android with XML or jetpack compose , I am good with flutter nd been doing from last 8 months
@harshar6897
@harshar6897 3 жыл бұрын
Could you explain why or how service locator pattern is called an anti pattern ?
@vibovitold
@vibovitold Жыл бұрын
It can hide dependencies, plus when it's misconfigured (eg. some dependency is not defined), there's a risk you will only find out by a runtime error instead of a compile-time error. It's about trade-offs though. Koin is a service locator, and it's not bad 0 especially if your project isn't very big; in that case the simplicity of Koin may be worth it.
@nihal999in
@nihal999in 3 жыл бұрын
U are awesome bro.. please grow your beard.. you look damn handsome in that look. Apart from this, your biggest fan. You teach and explain things in different level. Love it bro . 😊
@Scamparelli
@Scamparelli 3 жыл бұрын
Hey Philipp, thank you for the excellent video - your explanations are really nice to watch and I like that small errors are left in (such as in the return statement in the 'factory' example), however I really, really, REALLY struggle with dependency injection. I just can't understand how I would implement it or how I would change my app to use this pattern.. I hope I am not alone! I would therefore really appreciate it if you would do a video where you start with a simple existing design that you convert to use dependency injection to show the benefits of this methodology.. thank you!! (you did ask for suggestions!). Oh and I work in Kotlin so I'm happy I can avoid the builder pattern!!
@karentechnologies3990
@karentechnologies3990 3 жыл бұрын
Thanks Phillip for this useful video. please make a complete series for design patterns and best practices for Android developer, one more please make a series for memory management in Android. Thanks
@devendravarma5074
@devendravarma5074 3 жыл бұрын
Can we get a video like 'Testings made esay with dagger', which will demonstrate the fake repository pattern that you just explained in this video
@PhilippLackner
@PhilippLackner 3 жыл бұрын
I have a whole playlist on testing with dagger hilt and stuff like that
@devendravarma5074
@devendravarma5074 3 жыл бұрын
@@PhilippLackner thanks a lot, I have gone through that playlist and it was really helpful!
@devendravarma5074
@devendravarma5074 3 жыл бұрын
@@PhilippLackner How about a video for: "The best to secure keys for production apps"
@chimezieorji-unegbu7110
@chimezieorji-unegbu7110 3 жыл бұрын
Excellent video as always
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks again!
@zafar_codes
@zafar_codes 3 жыл бұрын
Thanks for good video, we would more videos about Jetpack compose, especially architecture of these apps
@matt-g-recovers
@matt-g-recovers 3 жыл бұрын
He's already done 3 playlists on compose, some advanced dev stuff is welcomed.
@ahmednashwan8111
@ahmednashwan8111 3 жыл бұрын
❤️❤️❤️👌👌 perfect
@bboydarknesz
@bboydarknesz 3 жыл бұрын
soo that's how they call Builder pattern and tutorial to make it. Man you best! But I don't know when I will make Builder pattern with Kotlin.
@awais2980
@awais2980 3 жыл бұрын
Thanks Philipp for the video ❣️
@PhilippLackner
@PhilippLackner 3 жыл бұрын
My pleasure!
@mohammadrezarahmani3731
@mohammadrezarahmani3731 3 жыл бұрын
Please make a free tutorial for Ktor
@MegaArti2000
@MegaArti2000 2 жыл бұрын
I think it got too abstract at some point, maybe some bigger examples would be more useful for understanding each pattern, but thx for the video anyway
@kamertonaudiophileplayer847
@kamertonaudiophileplayer847 2 жыл бұрын
Developers may know, but Google Android managers have no idea that DSF and DFF are audio files too.
@LaDaDee
@LaDaDee 2 жыл бұрын
Are you copying Ahmad Kazimi's article or is he copying from you?
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Looking at the publish date of each, that should be clear 😂
@adnanomerovic5487
@adnanomerovic5487 3 жыл бұрын
Nice!
@calvindeceuster878
@calvindeceuster878 3 жыл бұрын
Just give me my freakin hamburgers! Thank you
@DiabloZq
@DiabloZq 3 жыл бұрын
Thank you!
@PhilippLackner
@PhilippLackner 3 жыл бұрын
You're welcome!
@withinloop
@withinloop 3 жыл бұрын
Thanks lot Brother
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Welcome
@niranz7745
@niranz7745 3 жыл бұрын
More videos!
@TidelxD
@TidelxD 2 жыл бұрын
Nice
@rajushingadiya2860
@rajushingadiya2860 3 жыл бұрын
perfact
@MaisUmSomente
@MaisUmSomente 3 жыл бұрын
awsome
@fyanahmad9418
@fyanahmad9418 3 жыл бұрын
Practice make perfect
@PhilippLackner
@PhilippLackner 3 жыл бұрын
true
@shriharshsistla614
@shriharshsistla614 3 жыл бұрын
Shit I missed the Live 😭
@ramasubramanian3154
@ramasubramanian3154 3 жыл бұрын
Awesome info. Is there a way to use binding in persistant bottom sheet? If we dont use kotlin synthetics.. We could use binding for normal dialogs, acticities, fragments to acess the views easily. But for persisten bottom sheet it doesn't seem to work? Any idea how to use it?
@erfansn869
@erfansn869 3 жыл бұрын
Good an quastion how to use service and inside it state flow in mvvm?
@swaminathbera6407
@swaminathbera6407 3 жыл бұрын
How to do Configuration for debug app and for release app. Like how to remove/hide log or classes or default values that you don't need in production app but needed for debug app
@syedovaiss
@syedovaiss 3 жыл бұрын
You missed repository pattern 😛
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Sure, there are more, observer would also be a common one. But somewhere I need to draw a line 😁
@mosesaltruism518
@mosesaltruism518 3 жыл бұрын
Nice Video. Could you find time and do a tutorial on app modularization?? Would really appreciate.
@arshsethi8596
@arshsethi8596 2 жыл бұрын
most of it went over my head but alright
@ardit9988
@ardit9988 3 жыл бұрын
😃
@MikeBurke
@MikeBurke 2 ай бұрын
There is no such thing as a singleton. You will always have 1 instance for production and 1 instance for testing. Singleton is better enforced through dependency injection by convention.
@PhilippLackner
@PhilippLackner 2 ай бұрын
Why do you always have one instance for anything? The moment you create an instance in a ViewModel or Activity, it's by definition not a singleton
@MikeBurke
@MikeBurke 5 ай бұрын
Singleton 🤮
@abuiman5251
@abuiman5251 3 жыл бұрын
Hi, Philipp, I've sent you a message in Instagram. Could you please check it! P.s. thanks for the great videos!👍🏻👍🏻👍🏻
5 Fatal Coroutine Mistakes Nobody Tells You About
18:15
Philipp Lackner
Рет қаралды 90 М.
7 Design Patterns EVERY Developer Should Know
23:09
ForrestKnight
Рет қаралды 259 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
Make Your Code Clean With the SOLID Principles
18:24
Philipp Lackner
Рет қаралды 103 М.
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Рет қаралды 57 М.
8 Design Patterns | Prime Reacts
22:10
ThePrimeTime
Рет қаралды 455 М.
What Is the Best Architecture for Android Apps?
17:57
Philipp Lackner
Рет қаралды 59 М.
Let, Also, Apply, Run, With - Kotlin Scope Functions
11:44
Philipp Lackner
Рет қаралды 100 М.
8 Design Patterns EVERY Developer Should Know
9:47
NeetCode
Рет қаралды 1,1 МЛН
How to Make Your Code Clean With Kotlin Sealed Classes
18:09
Philipp Lackner
Рет қаралды 42 М.
Flow Basics - The Ultimate Guide to Kotlin Flows (Part 1)
17:26
Philipp Lackner
Рет қаралды 141 М.
10 Design Patterns Explained in 10 Minutes
11:04
Fireship
Рет қаралды 2,4 МЛН
Kotlin Code Reuse: Composing like you're Inheriting
14:42
Dave Leeds
Рет қаралды 11 М.