Make Your Code Clean With the SOLID Principles

Поділитися
Вставка
  • Опубліковано 21 гру 2024

КОМЕНТАРІ • 242

  • @iamkrishn
    @iamkrishn 3 роки тому +172

    0:00 Introduction
    0:51 Find problem with existing code
    1:36 S = Single Responsibility Principle
    4:05 O = Open Extensions, Closed Modifications
    7:09 L = Liskov Substitution
    9:43 I = Interface Segregation
    11:31 D = Dependency Inversion
    Great explanation with a simple to understand example. Amazing videos as always.

  • @SlakySlaky
    @SlakySlaky 3 роки тому +125

    Play the video in 2x speed then you'll be learning SOLID in 10 minutes

    • @feepin2058
      @feepin2058 3 роки тому +11

      But you will understand 2x less as well

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

      @@feepin2058 not necessarily

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

      Lmao

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

      So scary 😂

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

      Writing code is simple but writing simple code is difficult. Good work Philip, it helped me to learn SOLID principles 😅

  • @aimenham4685
    @aimenham4685 3 роки тому +30

    finally , now i understand why interfaces are so important ,I struggled so much to find reason to use them , Thank you philipp

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

      Same here

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

      Me too... I knew what an interface is in general, but not what it really means in coding (at least I had a bright moment)...

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

    Experience is so freaking important!.
    6 months ago, i saw this video i didnt understand anything of it.
    Now i understand everything! Because without knowing, i used all of this on my job, day to day on Android.
    Excelent!
    Now going for theory behind design patterns

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

    Hi!) I am from Russia and I am learning English to find a job in another country. You have good English I understand almost everything and your videos help me to learn the language))

  • @Alchemist10241
    @Alchemist10241 3 роки тому +51

    For Interface segregation principle; I think we shouldn't create a function (that sometimes needed and sometimes not) - printLogs() function in this video - inside the same interface, We should create another interface and declare this function in it and if we need this functionality we can implement this interface and plus other interfaces like FileLogger interface in this video

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

      Agree! But the video still is amazing.

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

      You're right

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

      That's what I thought. Apart from that, video was good.

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

      Yeah! I did note that and agree with your response!

    • @diegohkdfln
      @diegohkdfln 8 місяців тому

      Also agree. If I have an instance of FileLogger and call printLogs(), I'd expect it to print the logs, but it won't. Moving the printLogs() to a separate interface such as LogPrinter, would make more sense.

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

    I got goosebumps when he said, "This changes the entire implementation in one line of code. 🦋"

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

    The video we didn't ask for, but really needed..

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

    I would've killed for this video when I first started learning Android and programming; Thank you.

  • @vonn9737
    @vonn9737 2 роки тому +12

    In example for open/closed, you treated the FileLogger class as being completely closed. Your CustomFileLogger was effectively another implementation of a FileLogger interface. It is ok to add new functionality to the FileLogger class, for example adding another function called timestampedError(), as long as you do not change the logError() function it adheres to the open/closed principle. All existing consumers of FileLogger will work exactly as they did before.
    For your example of Liskov substitution, the CustomErrorLogger class does not violate Liskov substitution. All instances of FileLogger can be replaced with CustomErrorLogger and will work exactly the same. This is because all calls to logError() will still go to the base FileLogger via inheritance.

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

      Your explanation is great. But, I have a question here, we already have a function named logError() in class FileLogger. So if we add timestampedError() to FileLogger it is not violating single resposibility principle? Kindly help me understand better

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

      @@avigneswaranwaran well ... first of all timestampedError is not a good function name IMO. I follow the pattern of naming a function with a verb prefix. That, plus vonn didn't say what that function does makes it hard to know what vonn intends that function to do. But ... if that function is about logging to a file (logs a timestamped error?) then it does adhere to single responsibility (SR). Then again, vonn's comment is about Open/Closed (O/C) ... why are you asking about SR?

  • @ani-eg8dy
    @ani-eg8dy 3 роки тому

    This is simple AF , nobody showed this important principle with this level of simple and easy examples ! Take a bow @Philipp

  • @kobeissi721
    @kobeissi721 3 роки тому +8

    For the optional interface function, you could also do = Unit instead of the empty function braces.

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

      Yea sure was just a quick demo here

    • @BilalBerek-tl3tq
      @BilalBerek-tl3tq 9 місяців тому +1

      @@PhilippLackner I think you must do make separate interfaces for every method. So you can use multiple inheritance for every method you need. Because function with empty body standing in the interface not a good case that much.

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

    Bro, you are my new superhero, much much better than any other fictional superhero

  • @vitorferreira5464
    @vitorferreira5464 9 місяців тому

    Best video about SOLID I've ever seen

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

    Thank you for your content Philipp! It helps so much and I'm glad there are developers who strive to make code as good as possible!

  • @tgamings1
    @tgamings1 7 місяців тому

    Vielen vielen Dank lieber Philipp für diese tolle Erklärung. Du hast da wirklich ein Talent solche Dinge sehr einfach für jeden verständlich zu machen.
    Liebe Grüße aus Österreich.

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

    This is a most important video in the internet for devs today. It's not easy to explain this topic the way he did. Kudos @Philipp

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

    I finally understand them now, I faced the same problem when searching them online...very hard to understand. This was waaay easier to understand. Thank you!

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

    awesome man. I didn' like you previously when seen on interviews but Now addicted to how you teach and how humble you really are.

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

    Been binge watching all your recent videos. Amazing Android content 👏🏽 👌🏽

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

    You have such a nice way of explaining things brother. Keep making these videos please. Thank you.

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

    I watched this video after watching your multi module course. So clearly explained .. I clearly understand why you inject abstractions using hilt instead of concrete implementation ..... Thank you so much Philip

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

    This guy does it again!!! Nice explanations.

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

    Philip God bless you soooooooo much.... i can't thank you enough

  • @pratikpattanaik
    @pratikpattanaik 2 роки тому +10

    I think a more appropriate example of Liskov substitution principle would be if an overriden function were to do something unexpected and contrary to its implementation in the base class. This can be shown with a base function that changes the state of the class which is overriden by a function that doesn't call the super method. The example provided doesn't break this principle. I liked the other explanations.

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

    After watching this last night I went back and re-watched Bob's playlist on clean code... outstanding!
    Then today in a long term project interview (We interview internally for projects) I was asked, 'what are the SOLID principles of good software engineering?'
    I played it cool,
    .. 'fools, little do you know Phillipp just schooled me on this shit'
    ... barely had the words come out of my mouth when the hiring manager said "wait you know Phillipp?" ;)
    Joking aside, the synchronicity is insane man, thanks so much for everything!

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

    The thing that I liked about the video was not wasting my time to learn this SOLID buillshit. Thanks for summarizing.

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

    really the most informative explanation of SOLID principles. appreciated and thanks a lot man:)

  • @umairkhalid123
    @umairkhalid123 3 роки тому +4

    You got some perfect communication skills

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

      Thanks ❤️

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

      @@PhilippLackner Great video. I do have one doubt regarding auth in Dependency inversion. If we call auth.signInWithEmailAndPassword(), then which would be called among the functions in FirebaseAuthention and CustomApiAuthentication classes?Thanks in advance

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

      @@satyasaineelapala570 you have to pass authenticator object while creating instance of Repository, if you've passed firebaseAuthenticator then it'll use that, and vice versa

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

      @@mrwhoknows Thanks

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

    Thanks for the explanations with easy examples 👌👏

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

    The best explanation I have ever seen. Great job

  • @kareemjeiroudi1964
    @kareemjeiroudi1964 3 роки тому +16

    Well done video. Just pay attention to interface segregation. Interface segregation does not mean that clients do not need to implement the entire interface. It means that you should segregate different functions under several interfaces, and then it's up to the client to decide which interfaces to implement. I don't think the example here was demonstrative of interface segregation.

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

      agreed, thanks for the feedback!

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

      Probably onClickListener and OnLongClickListener are examples of it. Those 2 could be in a single interface, but that way you would have forced the class to implement these 2 methods even you want to use either of them.

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

    Kudos Philip. This explanation was easy to grasp

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

    Thankyou Philipp, your way of explaining the issues through examples is just amazing. Thankyou for this great video.

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

    I like how you explain complex things so easy👍nice

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

    Thank you so much dear philipp for record this courses ,
    I just wanted say i love you ❤️😘

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

    This is literally one of the best channels out there. I can’t believe that I only found it now. I love the videos. Keep them coming!
    P.s- would love to see a video about Alarm manager in Kotlin! Looking for such a video for a while.

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

    This guy is really good.... Keep it up bro

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

    Thanks for this video man!, Big fan of your channel

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

    Simplest and best example with clean examples just like your clean codes @Philipp ! Awesome :)

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

    This is by far the best SOLID video explaining these complex SOLID software principles !! Thank you for this amazing content !!

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

    Amazing video, I have studied the SOLID principles and I have never understood them so easily, congratulations, greetings from Caracas, Venezuela

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

    Thanks a lot for that awesome explanation!

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

    Just the thing I needed.
    Surely will start using all these principles in my future projects.... Thanks bro...

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

    Thank you so much for clear explanation of SOLID 🙏

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

    You explain like Indians ❤ simple and easy to understand with examples.

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

    So realy clearest explanation ever and simple practical
    Thank you Philipp

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

    Really amazing video

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

    This is really helpful,some tutorial only targets output without considering clean code,thanks Philipp

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

    Thank you for the explanation I learned something new today

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

    thanks' a lot Philipp, appreciated your efforts

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

    Finally found a Bible for SOLID.❤️🙏

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

    Keep making such videos.👍 It truly helps a lot.😌 Thank you 🙏🙂

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

    Thank you it was very simple and easy to understand

  • @theLaughRiot00
    @theLaughRiot00 3 роки тому +8

    Hey Philipp , What about MVI pattern?Can we have any tutorial on it. Thanks

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

    Great content. You made it clear for me. Thank you so much.
    .
    .
    .
    Thank you so much.

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

    do you have an example of project with clean arhitecture?

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

    Someone actually disliked this gem of a video...??! Outrageous...

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

    Great video Philipp, would be awesome if you would cover more of these advanced topics. Keep up the good work!

  • @NishantKumar-cr6fb
    @NishantKumar-cr6fb 3 роки тому

    Nicely and simply explained

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

    This videos was so helpful. Thank you

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

    Please make more videos like this !

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

    Thanks man. Really helpful.

  • @MenaSamer
    @MenaSamer 6 місяців тому

    it is good, but I need the new version of this video ... if you have a chance to do it.

  • @d-landjs
    @d-landjs 7 місяців тому

    Excellent bro !

  • @OmarMohamed-ge2zg
    @OmarMohamed-ge2zg 4 місяці тому

    thank you mr philipp

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

    Didn't realize I already did all of it long time ago.

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

    Hey Phillipp we need more videos on clean architecture, if possible please make a playlist on it. I will buy that playlist if it is paid but please make that playlist

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

    Great explanation man! Thank you!

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

    If possible also make a video on Design Patterns 😅

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

    Very good video. One question regarding the Open Closed Principle: If I would create method for changing the path e.g.: open fun getPath(){...} Does this violate the principle?

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

    Thanks. Very good explanation.

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

    Can you please make video on Important design patterns for Android developers?
    Thanks in advance.

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

    thank you very much , this is really awesome

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

    need to watch some more time. Thanks a lot

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

    Please Make A Series About Clean Architecture...

  • @behnawm
    @behnawm 3 роки тому +4

    Perfection!

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

    Well, guess I'll be here for the rest of my college, bout to dive head first into android dev.

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

    great material, very helpful, thanks !

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

    I always enjoy your videos. Would u do one video on adding time and date in an android studio app

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

      Thanks I do that in a bunch of my Playlists

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

    Thanks philipp

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

    Hi Philipp.... Could you please do a video on How to use Ktor on an Android client...

  • @TheCreator1197
    @TheCreator1197 2 роки тому +2

    For the open-closed principle, would you then be violating it if you provided a default parameter with the file path name, so that one could change the output location without extending the original class? Not sure if that's what you mean by closed to modification

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

    Really awesome explanation 😐😐👏

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

    On the single responsibility principle example, shouldnt the error handling part be implemented in a different class? I mean it sounds and would look weird, but in principle this class still has more than one reason to change: 1. if we want to change how the user sign-in network call is implemented 2. if we want to change how the error handling works. I mean the logging part is in another class, so if we want to change only the error logging than everything is good, but if we want to change what gets called in the catch block in the first place than the class would have two reasons to change.

    • @VikashKumar-t3v8z
      @VikashKumar-t3v8z Рік тому

      Somewhere you need to catch the possible exception. I think there is no other option to handle exception like writing try-catch in the same function. If you find some solution please share that might help to understand more. Thanks

  • @atulkumar-bb7vi
    @atulkumar-bb7vi Рік тому

    I liked explanation, Thanks! but Interface segregation principle is not explained properly. It states that, should have kept printLogs method in different interface and then can be implemented in classes wherever required.

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

    Awesome video!!

  • @HasanKhan-ol2no
    @HasanKhan-ol2no 3 роки тому

    For liskov princple you can replace the filelogger with custum logger class

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

      Sure you could but it won't work how a file logger is intended to work

    • @HasanKhan-ol2no
      @HasanKhan-ol2no 3 роки тому

      @@PhilippLackner no i am saying in repo class? Will it ne good or bad

    • @HasanKhan-ol2no
      @HasanKhan-ol2no 3 роки тому

      I am always confused with interface and inheritance class

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

      @@HasanKhan-ol2no no that's bad because then you couldn't replace it with another logger. You're forced to pass the custom one

    • @HasanKhan-ol2no
      @HasanKhan-ol2no 3 роки тому

      One more question : if i add parent class as dependency in repo class and then when I create a new instance and replace parent class with child class then it will be good pratice or not??

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

    1:36 A module should be responsible to one, and only one, actor. © Uncle Bob

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

    Sir, u are the best!

  • @atulkumar-bb7vi
    @atulkumar-bb7vi Рік тому

    Repo is dependent on FirebaseAuth object which is wrong, Should be asbtracted and repo should also be abstracted with separating out implementation, and separate class for logging code.

  • @carguy-xv2cl
    @carguy-xv2cl Місяць тому

    Am I crazy or did you not instantiate any of the class member objects that you are calling methods from. Still trying to get the hang of kotlin coming from java.

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

    Brilliant content

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

    Do we need to remove dependency on concretion of FileLogger class?
    For "I" principle you can split your interface in several interfaces.
    Thanks for video! ❤

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

    is there somewhere that you put this code? thanks!

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

    Superb!!

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

    thanks, it looks very easy to understand. Do you have any video about customizing views in android?

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

    Can you please make medium scale app with clean architecture so we can practice on it.

  • @SandeepRajput-mq4mf
    @SandeepRajput-mq4mf 3 роки тому +2

    Please make video on things we do wrong, without even knowing it.

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

    Its good to see the stuff I usually do put into a list.. notice I said USUALLY hehe