6 Design Patterns Every Android Developer Must Know

Поділитися
Вставка
  • Опубліковано 29 вер 2024
  • Design patterns are nice solutions to common problems in programming. As Android developer there are a few you must know. You'll learn about them in this video.
    ⭐ 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/...
    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...

КОМЕНТАРІ • 123

  • @LinggarMaretvaCendani
    @LinggarMaretvaCendani 3 роки тому +137

    0:49 Singleton
    2:46 Factory
    5:04 Builder
    8:31 Facade
    9:44 Dependency Injection
    12:30 Adapter

  • @shalatan
    @shalatan 3 роки тому +73

    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 роки тому +32

      cool idea, will think about it

    • @bboydarknesz
      @bboydarknesz 3 роки тому +10

      @@PhilippLackner clean architecture. wow, cant wait! Hope it also support for REST API, login, token, handle expired token

    • @chatgpt-undetected
      @chatgpt-undetected 2 роки тому +3

      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 Рік тому +1

      good idea

    • @SebastianHasch
      @SebastianHasch 12 днів тому

      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.

  • @FaroukSonic
    @FaroukSonic 3 роки тому

    Thank you so much bro! I recently discovered your channel and it's super helpful! Great content!

  • @ghasemshirdel6933
    @ghasemshirdel6933 3 роки тому +1

    Thanks Philipp , I think some other patterns like Object Pool, Flyweight, Decorator, Observer, Strategy and Proxy has useful in a project

  • @shreyashchoudhary2637
    @shreyashchoudhary2637 3 роки тому

    Yeah! 2 of 6 I don't even heard before ❤️

  • @javacore-qk9kd
    @javacore-qk9kd 6 місяців тому

    you are the man of God💖💖💖💖

  • @devgabriel6898
    @devgabriel6898 4 місяці тому

    Saw this video (AMAZING) 2 years ago and now Android has also lift us of that horrible recycler views adapters thanks to Compose xD

  • @shoaibkhalid6156
    @shoaibkhalid6156 3 роки тому

    Amazing. Do you have any discord channels?

  • @muhammadmuzammil2575
    @muhammadmuzammil2575 2 роки тому

    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 10 місяців тому

      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.

  • @awais2980
    @awais2980 3 роки тому

    Thanks Philipp for the video ❣️

  • @adnanomerovic5487
    @adnanomerovic5487 3 роки тому

    Nice!

  • @syedovaiss
    @syedovaiss 3 роки тому

    You missed repository pattern 😛

    • @PhilippLackner
      @PhilippLackner  3 роки тому +1

      Sure, there are more, observer would also be a common one. But somewhere I need to draw a line 😁

  • @newbiegameplayy
    @newbiegameplayy 3 роки тому +28

    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 🙏🏻

  • @lifeOfCharlesMaina
    @lifeOfCharlesMaina 3 роки тому +13

    You are the best Android and Kotlin teacher I have encountered!! Thank you Phillip...you are literally saving careers out here💯💯💯

  • @ronyaburaihan
    @ronyaburaihan 3 роки тому +2

    Can you create a video for webrtc for Android?

  • @mustaqode_6617
    @mustaqode_6617 3 роки тому +6

    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.

  • @ibrahimkhalilshakir2414
    @ibrahimkhalilshakir2414 3 роки тому +2

    Great job. Please make an e-commerce or Video calling app tutorial 😊

  • @voidpointer398
    @voidpointer398 3 роки тому +6

    As always, unique content.
    Thanks man ❤

  • @LaDaDee
    @LaDaDee Рік тому +1

    Are you copying Ahmad Kazimi's article or is he copying from you?

    • @PhilippLackner
      @PhilippLackner  Рік тому

      Looking at the publish date of each, that should be clear 😂

  • @matt-g-recovers
    @matt-g-recovers 3 роки тому +6

    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.

  • @ErikBongers
    @ErikBongers 2 місяці тому

    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.

  • @vengateshm2122
    @vengateshm2122 3 роки тому +3

    Excellent. Interview prep material.
    Decorator - Modifying an object during runtime.
    Eg: Recycler view item decorator

    • @vengateshm2122
      @vengateshm2122 3 роки тому +1

      Feeling overwhelmed when getting a love for my comment from the creator who is 1000s of miles apart. Thanks to the technology.

  • @InaAgapito
    @InaAgapito 3 роки тому +2

    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?

  • @nihal999in
    @nihal999in 2 роки тому

    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 . 😊

  • @MegaArti2000
    @MegaArti2000 Рік тому

    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

  • @alix3665
    @alix3665 5 місяців тому

    GOD I Needed this video...
    FUCKIN LOVE YOU PHILIP❤❤

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 2 роки тому

    Developers may know, but Google Android managers have no idea that DSF and DFF are audio files too.

  • @FatLlama31882
    @FatLlama31882 2 роки тому +4

    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 10 місяців тому

      "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 10 місяців тому

      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.

  • @Akira-sh7ts
    @Akira-sh7ts 2 роки тому

    stupid question
    In frontend web dev why we need to learn design patterns because I am learning react and never saw this things....

  • @samdroid37
    @samdroid37 2 роки тому

    please make a video over page object model pattern for testing with kotlin!

  • @devgabriel6898
    @devgabriel6898 2 роки тому

    Is Observer one of them and very used in Android too? Or im wrong?

  • @bezelyesevenordek
    @bezelyesevenordek Рік тому

    facade is like mcdonalds i dont want to see how the bigmac is made

  • @calvindeceuster878
    @calvindeceuster878 2 роки тому

    Just give me my freakin hamburgers!
    Thank you

  • @darksoul2474
    @darksoul2474 2 місяці тому

    Make video for Android Google interviews

  • @jaygitonga2026
    @jaygitonga2026 3 роки тому +1

    As always great videos Phillip! Do a tutorial on clean architecture or mvi

  • @iliass1
    @iliass1 3 роки тому

    I like the way you teach, so cool. I learnt a lot from you. thanks bro

  • @DARKcarlos1
    @DARKcarlos1 3 роки тому +1

    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

  • @arshsethi8596
    @arshsethi8596 2 роки тому

    most of it went over my head but alright

  • @mkc0321
    @mkc0321 Рік тому

    the best time i spend on youtube is seeing your videos

  • @righteouscoder
    @righteouscoder 2 роки тому +1

    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 10 місяців тому

      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".

  • @akeeaggarwal8087
    @akeeaggarwal8087 3 роки тому +1

    You have made them super easy for us to understand. Thanks man.👍

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

  • @mohammadrezarahmani3731
    @mohammadrezarahmani3731 3 роки тому

    Please make a free tutorial for Ktor

  • @rba6486
    @rba6486 2 роки тому +1

    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 10 місяців тому

      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.

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

  • @MikeBurke
    @MikeBurke Місяць тому

    Singleton 🤮

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

  • @devendravarma5074
    @devendravarma5074 3 роки тому +1

    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 роки тому +1

      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 роки тому +1

      @@PhilippLackner
      How about a video for: "The best to secure keys for production apps"

  • @JavierMartinez-kc2ps
    @JavierMartinez-kc2ps 2 роки тому

    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

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

  • @subindsuresh4897
    @subindsuresh4897 2 роки тому

    Thank you bro.

  • @Sc2MooDy
    @Sc2MooDy 3 роки тому

    Thank you for this video, please keep making those kind of videos :D. I suggest one about gradle

  • @MaisUmSomente
    @MaisUmSomente 3 роки тому

    awsome

  • @TidelxD
    @TidelxD 2 роки тому

    Nice

  • @sunildhakar078
    @sunildhakar078 3 роки тому

    Hi, Philipp Great job. can you create a video on app performance for big apps?

  • @theophilus494
    @theophilus494 3 роки тому

    Great and lovely video... Kindly make tutorials on dagger. Thank you boss..

  • @rajushingadiya2860
    @rajushingadiya2860 2 роки тому

    perfact

  • @krhijaerhtuirthsirthu164
    @krhijaerhtuirthsirthu164 Рік тому

    Podrias explicarme mas detalladamente como implementar el patron Factory en mi proyecto porfavor ?

  • @ardit9988
    @ardit9988 2 роки тому

    😃

  • @alirohmansyah7914
    @alirohmansyah7914 3 роки тому

    thanks philipp. btw have you ever made a video about rxjava ?

  • @sat_talk
    @sat_talk 3 роки тому

    Great video.. Pl. make a project on Forum App or Polling App

  • @Coldalecs
    @Coldalecs 2 роки тому

    Loved it! I like how easy is to understand from what you explain.

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

  • @asifmehmood9307
    @asifmehmood9307 2 роки тому

    great information it's help full for me great effort bro

  • @Scamparelli
    @Scamparelli 2 роки тому

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

  • @techmarinar
    @techmarinar 3 роки тому

    Thanx man this was very very helpful 😊

  • @new_kind_of
    @new_kind_of Рік тому

    Simplied and to the point. Good work Philipp 👏

  • @fyanahmad9418
    @fyanahmad9418 3 роки тому

    Practice make perfect

  • @josephmolina5477
    @josephmolina5477 3 роки тому

    Please continue to make more videos on these topics !

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

  • @ZaidZakir
    @ZaidZakir 3 роки тому

    Great video ☺️

  • @saumilpatel2480
    @saumilpatel2480 3 роки тому

    Very useful Phillip. Great content as always 👏👏👏

  • @yelamanmyrzahanov9883
    @yelamanmyrzahanov9883 3 роки тому

    As always, unique content and easy to watch
    Can you please make video about anti pattens in Android?

  • @pradeep9222
    @pradeep9222 3 роки тому

    it's awesome, thank you so much

  • @jam4l
    @jam4l 2 роки тому

    A great video as always, Ty.

  • @abhishekauti164
    @abhishekauti164 3 роки тому

    Hey man it was really helpful

  • @mare10rooney
    @mare10rooney 3 роки тому

    Another great video Philipp! Thanks for handling some of the advanced topics...

  • @harshar6897
    @harshar6897 3 роки тому

    Could you explain why or how service locator pattern is called an anti pattern ?

    • @vibovitold
      @vibovitold 10 місяців тому

      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.

  • @shriharshsistla614
    @shriharshsistla614 3 роки тому

    Shit I missed the Live 😭

  • @niranz7745
    @niranz7745 3 роки тому

    More videos!

  • @ahmednashwan8111
    @ahmednashwan8111 3 роки тому

    ❤️❤️❤️👌👌 perfect

  • @karentechnologies3990
    @karentechnologies3990 3 роки тому +1

    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

  • @mustaqode_6617
    @mustaqode_6617 3 роки тому

    Perfect as always.

  • @unaisulhadi9102
    @unaisulhadi9102 3 роки тому

    Excellent video Phil!!

  • @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!👍🏻👍🏻👍🏻

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

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

  • @mosesaltruism518
    @mosesaltruism518 3 роки тому

    Nice Video. Could you find time and do a tutorial on app modularization?? Would really appreciate.

  • @erfansn869
    @erfansn869 3 роки тому

    Good an quastion how to use service and inside it state flow in mvvm?

  • @withinloop
    @withinloop 3 роки тому

    Thanks lot Brother

  • @DiabloZq
    @DiabloZq 3 роки тому

    Thank you!

  • @chimezieorji-unegbu7110
    @chimezieorji-unegbu7110 3 роки тому

    Excellent video as always