Make Your Code Clean With the SOLID Principles

  Рет қаралды 102,353

Philipp Lackner

Philipp Lackner

Күн бұрын

Пікірлер: 242
@iamkrishn
@iamkrishn 3 жыл бұрын
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.
@raplyanugrah4412
@raplyanugrah4412 2 жыл бұрын
Vn
@raplyanugrah4412
@raplyanugrah4412 2 жыл бұрын
Vvvvvvvvv
@raplyanugrah4412
@raplyanugrah4412 2 жыл бұрын
Hv
@raplyanugrah4412
@raplyanugrah4412 2 жыл бұрын
Gvv
@raplyanugrah4412
@raplyanugrah4412 2 жыл бұрын
Ggvvv
@aimenham4685
@aimenham4685 3 жыл бұрын
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 Жыл бұрын
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)...
@SlakySlaky
@SlakySlaky 3 жыл бұрын
Play the video in 2x speed then you'll be learning SOLID in 10 minutes
@feepin2058
@feepin2058 3 жыл бұрын
But you will understand 2x less as well
@CybercoderNaj
@CybercoderNaj 3 жыл бұрын
@@feepin2058 not necessarily
@MateusMeurer
@MateusMeurer 3 жыл бұрын
Lmao
@newbiegameplayy
@newbiegameplayy 3 жыл бұрын
So scary 😂
@rahulmatte6621
@rahulmatte6621 3 жыл бұрын
Writing code is simple but writing simple code is difficult. Good work Philip, it helped me to learn SOLID principles 😅
@Alchemist10241
@Alchemist10241 3 жыл бұрын
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 жыл бұрын
Agree! But the video still is amazing.
@aliahmadabadiha3263
@aliahmadabadiha3263 2 жыл бұрын
You're right
@TheMohit987
@TheMohit987 2 жыл бұрын
That's what I thought. Apart from that, video was good.
@ltadeu61
@ltadeu61 2 жыл бұрын
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.
@devgabriel6898
@devgabriel6898 2 жыл бұрын
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 жыл бұрын
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))
@vonn9737
@vonn9737 2 жыл бұрын
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 жыл бұрын
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?
@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!
@Chintanparmar
@Chintanparmar 3 жыл бұрын
The video we didn't ask for, but really needed..
@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
@alwaysbrillant10
@alwaysbrillant10 2 жыл бұрын
Been binge watching all your recent videos. Amazing Android content 👏🏽 👌🏽
@tgamings1
@tgamings1 8 ай бұрын
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.
@kobeissi721
@kobeissi721 3 жыл бұрын
For the optional interface function, you could also do = Unit instead of the empty function braces.
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Yea sure was just a quick demo here
@BilalBerek-tl3tq
@BilalBerek-tl3tq 9 ай бұрын
@@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.
@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.
@Andrei1889
@Andrei1889 Жыл бұрын
I would've killed for this video when I first started learning Android and programming; Thank you.
@cesarlabastida1392
@cesarlabastida1392 Жыл бұрын
You have such a nice way of explaining things brother. Keep making these videos please. Thank you.
@CybercoderNaj
@CybercoderNaj 3 жыл бұрын
I got goosebumps when he said, "This changes the entire implementation in one line of code. 🦋"
@PhilippLackner
@PhilippLackner 3 жыл бұрын
This is programmer porn
@farazahmed7
@farazahmed7 2 жыл бұрын
What a nerd 💀
@mustaqode_6617
@mustaqode_6617 3 жыл бұрын
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
@sakhti007
@sakhti007 3 жыл бұрын
Thankyou Philipp, your way of explaining the issues through examples is just amazing. Thankyou for this great video.
@TripDude
@TripDude 2 жыл бұрын
Thanks for the explanations with easy examples 👌👏
@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!
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Glad it helped!
@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
@devetips
@devetips 2 жыл бұрын
really the most informative explanation of SOLID principles. appreciated and thanks a lot man:)
@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.
@Another0neTime
@Another0neTime 3 жыл бұрын
This guy does it again!!! Nice explanations.
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Glad you like them!
@mahdizareei4575
@mahdizareei4575 3 жыл бұрын
Thank you so much dear philipp for record this courses , I just wanted say i love you ❤️😘
@pratikpattanaik
@pratikpattanaik 2 жыл бұрын
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.
@vitorferreira5464
@vitorferreira5464 9 ай бұрын
Best video about SOLID I've ever seen
@daniyar2718
@daniyar2718 3 жыл бұрын
I like how you explain complex things so easy👍nice
@aginamabednego
@aginamabednego Жыл бұрын
Kudos Philip. This explanation was easy to grasp
@razidwa852
@razidwa852 2 жыл бұрын
The best explanation I have ever seen. Great job
@snehilsinha4689
@snehilsinha4689 2 жыл бұрын
Simplest and best example with clean examples just like your clean codes @Philipp ! Awesome :)
@theophilus494
@theophilus494 3 жыл бұрын
Philip God bless you soooooooo much.... i can't thank you enough
@alvaroisea2259
@alvaroisea2259 3 жыл бұрын
Thanks for this video man!, Big fan of your channel
@tinycontractor
@tinycontractor 2 жыл бұрын
The thing that I liked about the video was not wasting my time to learn this SOLID buillshit. Thanks for summarizing.
@matt-g-recovers
@matt-g-recovers 3 жыл бұрын
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!
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Haha thanks Matt! :D
@khanzadakashif8248
@khanzadakashif8248 3 жыл бұрын
Just the thing I needed. Surely will start using all these principles in my future projects.... Thanks bro...
@bjugdbjk
@bjugdbjk 3 жыл бұрын
This is by far the best SOLID video explaining these complex SOLID software principles !! Thank you for this amazing content !!
@VenewebTV
@VenewebTV 3 жыл бұрын
Amazing video, I have studied the SOLID principles and I have never understood them so easily, congratulations, greetings from Caracas, Venezuela
@shantanubopardikar7719
@shantanubopardikar7719 2 жыл бұрын
Bro, you are my new superhero, much much better than any other fictional superhero
@kareemjeiroudi1964
@kareemjeiroudi1964 3 жыл бұрын
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 жыл бұрын
agreed, thanks for the feedback!
@punerealestatebuilder
@punerealestatebuilder 3 жыл бұрын
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.
@Abhishek_Sawant
@Abhishek_Sawant 3 жыл бұрын
Keep making such videos.👍 It truly helps a lot.😌 Thank you 🙏🙂
@jhngolan
@jhngolan 3 жыл бұрын
So realy clearest explanation ever and simple practical Thank you Philipp
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks mate!
@haliltoprak585
@haliltoprak585 2 жыл бұрын
Thank you so much for clear explanation of SOLID 🙏
@mandroidx1474
@mandroidx1474 3 жыл бұрын
This is really helpful,some tutorial only targets output without considering clean code,thanks Philipp
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Glad you liked it
@wilsonahanmisi1187
@wilsonahanmisi1187 2 жыл бұрын
This guy is really good.... Keep it up bro
@lekshmiskrishnan5652
@lekshmiskrishnan5652 2 жыл бұрын
Thanks a lot for that awesome explanation!
@montuedge
@montuedge 10 ай бұрын
You explain like Indians ❤ simple and easy to understand with examples.
@vengateshm2122
@vengateshm2122 3 жыл бұрын
Finally found a Bible for SOLID.❤️🙏
@TheCreator1197
@TheCreator1197 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
@umairkhalid123
@umairkhalid123 3 жыл бұрын
You got some perfect communication skills
@PhilippLackner
@PhilippLackner 3 жыл бұрын
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 жыл бұрын
@@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
@mare10rooney
@mare10rooney 3 жыл бұрын
Great video Philipp, would be awesome if you would cover more of these advanced topics. Keep up the good work!
@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.
@sahilshokeen6078
@sahilshokeen6078 2 жыл бұрын
Really amazing video
@theLaughRiot00
@theLaughRiot00 3 жыл бұрын
Hey Philipp , What about MVI pattern?Can we have any tutorial on it. Thanks
@ramakrishnavjoshi
@ramakrishnavjoshi 3 жыл бұрын
Make video on this also please Phillip
@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?
@basitaliwrites4828
@basitaliwrites4828 2 жыл бұрын
Thank you for the explanation I learned something new today
@minasalah8210
@minasalah8210 2 жыл бұрын
thanks' a lot Philipp, appreciated your efforts
@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! ❤
@twominus7500
@twominus7500 6 ай бұрын
I do not understand why we need separate authenticator interface for Firebase. We already have an abstraction for repository and we can simply create another implementation with another dependencies. Why to double abstractions there?
@abood7meed509
@abood7meed509 2 жыл бұрын
Thank you it was very simple and easy to understand
@Chintanparmar
@Chintanparmar 3 жыл бұрын
If possible also make a video on Design Patterns 😅
@burakkarabekir459
@burakkarabekir459 3 жыл бұрын
Great content. You made it clear for me. Thank you so much. . . . Thank you so much.
@prasanthmanimaran5158
@prasanthmanimaran5158 3 жыл бұрын
Someone actually disliked this gem of a video...??! Outrageous...
@rizwansworld
@rizwansworld 5 ай бұрын
Thanks man. Really helpful.
@susanlama
@susanlama 3 жыл бұрын
This videos was so helpful. Thank you
@NishantKumar-cr6fb
@NishantKumar-cr6fb 3 жыл бұрын
Nicely and simply explained
@mohammedgouse5226
@mohammedgouse5226 3 жыл бұрын
Iam developing an app in java ..in that navigation drawer menu items are not getting clicked and not opening sir help as soon as possible
@pstlvictoras
@pstlvictoras 3 жыл бұрын
do you have an example of project with clean arhitecture?
@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
@amavrik
@amavrik 3 жыл бұрын
Great explanation man! Thank you!
@joemoe5954
@joemoe5954 3 жыл бұрын
Please make more videos like this !
@d-landjs
@d-landjs 7 ай бұрын
Excellent bro !
@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.
@merryorte
@merryorte 2 жыл бұрын
I think the explanation for open for extension but closed for modification was a bit confusing. I hope I'm understanding correctly that by modifying you mean adjusting functionality in pre-existing functions that already work fine.
@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
@bitwisedevs469
@bitwisedevs469 10 ай бұрын
Didn't realize I already did all of it long time ago.
@newbiegameplayy
@newbiegameplayy 3 жыл бұрын
Please Make A Series About Clean Architecture...
@awais2980
@awais2980 3 жыл бұрын
Can you please make video on Important design patterns for Android developers? Thanks in advance.
@r_yan3531
@r_yan3531 3 жыл бұрын
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
@OmarMohamed-ge2zg
@OmarMohamed-ge2zg 4 ай бұрын
thank you mr philipp
@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.
@RubabAzim
@RubabAzim 2 жыл бұрын
Nice explanation on very complex and ambiguous topic. 👍👍 Plus i think we can do diff approach for interface segregation instead of giving default implementation.
@funnymoment9164
@funnymoment9164 3 жыл бұрын
Thanks. Very good explanation.
@jayantkumar1954
@jayantkumar1954 3 жыл бұрын
Really awesome explanation 😐😐👏
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thanks bro!
@mackomako
@mackomako 3 жыл бұрын
I believe you got the Liskov Substitution principle wrong. The principle is that you should not override the behavior of the parent class. Let's say the method of the parent class changes an attribute of the parent class which depends on it. Then when the child class overrides the method and changes the behavior so the attribute is not changed in a way the parent class expects. So this leads to bugs such as when the parent class is used in a code, it expects the behavior of the parent class and if it is substituted by the child implementation, the behavior is changed. In your example, when you added a new function, that's ok. It doesn't break the parent class. I don't think your example is good. There is a good example with rectangle and square. Just google it :) Anyways, good job explaining the rest :)
@puszkinowski
@puszkinowski 3 жыл бұрын
great material, very helpful, thanks !
@techmarinar
@techmarinar 3 жыл бұрын
thank you very much , this is really awesome
@akashkumardas9670
@akashkumardas9670 3 жыл бұрын
need to watch some more time. Thanks a lot
@gugapadilha6945
@gugapadilha6945 2 жыл бұрын
is there somewhere that you put this code? thanks!
@MenaSamer
@MenaSamer 6 ай бұрын
it is good, but I need the new version of this video ... if you have a chance to do it.
@rogercolque
@rogercolque 3 жыл бұрын
saw videos about this topic and this helps me to understood it better. easy to undertand also for stating with solid and why use it half of the video after that i lost
@pranavyeole102
@pranavyeole102 3 жыл бұрын
Well, guess I'll be here for the rest of my college, bout to dive head first into android dev.
@behnawm
@behnawm 3 жыл бұрын
Perfection!
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Thank you!
@thomaswaldorf2829
@thomaswaldorf2829 3 жыл бұрын
Its good to see the stuff I usually do put into a list.. notice I said USUALLY hehe
@rezarizky8470
@rezarizky8470 3 жыл бұрын
Sir, u are the best!
@anudeepananth
@anudeepananth 3 жыл бұрын
Hi Philipp.... Could you please do a video on How to use Ktor on an Android client...
@toyboatt
@toyboatt 2 жыл бұрын
The Liskov example is incorrect, because the child class still implements the parent class's method and still serves as an appropriate substitute. In this example the child class fails to implement it's own method, but still successfully fulfills the parent class method.
@SriHarshaChilakapati
@SriHarshaChilakapati 3 жыл бұрын
Making everything final by default in Kotlin seems to be discouraging the rule O, as in use an interface but do not extend. What are your thoughts regarding this?
@manishkumarvats5058
@manishkumarvats5058 3 жыл бұрын
I am happy to see you here, as i can say that i am on good path after seeing u here
@PhilippLackner
@PhilippLackner 3 жыл бұрын
That's a good question! The approach from kotlin is making everything immutable by default which minimizes bugs. So also classes shouldn't be able to be extended by default. What I would say to this: if you don't want a class to have children it shouldn't be able to have some. But if you want to later modify an existing class, it's usually better to do that via the child classes (unless you really want to change the default behavior of it)
@SriHarshaChilakapati
@SriHarshaChilakapati 3 жыл бұрын
@@PhilippLackner The same was possible in Java, that is one can explicitly mention that the class is final and not to be extended when enforcing immutability. I really like what Kotlin did here, but not sure if it is not a discouragement on using extensible objects. Thanks for the video btw, your explanation is really SOLID!
@SriHarshaChilakapati
@SriHarshaChilakapati 3 жыл бұрын
@@manishkumarvats5058 Never expected to see this comment, but thanks!
@vathsan3906
@vathsan3906 3 жыл бұрын
With these vdo, I've understood what SOLID is.. Will you make a playlist making another project following MVVM, SOLID, Jetpack Compose etc... it would be nice
@PhilippLackner
@PhilippLackner 3 жыл бұрын
Planned for future yes, but not a specific date yet
@vathsan3906
@vathsan3906 3 жыл бұрын
@@PhilippLackner would love it if it comes ASAP.. maybe some app related to sports ....
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Рет қаралды 54 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 307 М.
6 Design Patterns Every Android Developer Must Know
14:16
Philipp Lackner
Рет қаралды 83 М.
I Rewrote This Entire Main File // Code Review
16:08
The Cherno
Рет қаралды 180 М.
Shrink, Optimize and Secure Your App With R8 & ProGuard - Full Guide
18:08
Uncle Bob’s SOLID Principles Made Easy 🍀 - In Python!
19:09
ArjanCodes
Рет қаралды 305 М.
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН