Christopher Okhravi
Christopher Okhravi
  • Видео 209
  • Просмотров 7 397 841
Liskov Substitution Principle (SOLID)
Violating the 7 rules of the Liskov Substitution Principle (L in SOLID) leads to code that is difficult to reason about. The 3 type rules can be checked by compilers but the 4 behavioral rules have to be respected by us developers.
⭐️ More about LSP in Clean Architecture (Chapter 9): geni.us/IBhtLnh
Watch First: ruclips.net/video/FdFBYUQCuHQ/видео.html
📄 The paper: dl.acm.org/doi/pdf/10.1145/197320.197383
🏛️ Design By Contract: en.wikipedia.org/wiki/Design_by_contract
CONTENTS
00:00 Intro
01:33 Formal Definition
02:56 Robustness Principle
06:09 Type Rules
08:50 Terminology
11:59 Behavioral rules
19:15 Conclusion
Просмотров: 6 564

Видео

8 Wastes of Lean (for Software Developers)
Просмотров 8 тыс.День назад
Applying the 8 Wastes (mudas) of Lean Manufacturing to Software Development helps us understand how to produce more value ✨, with less waste 🗑️. Check out the books below: 🚀 geni.us/iP1SF (Lean Startup) 🚘 geni.us/mgAIH8G (Toyota Way) 🎯 geni.us/BXDX (The Goal) CONTENTS 00:00 Intro 00:16 What is Lean? 01:15 Overproduction 02:17 Overprocessing 03:33 Defects 04:36 Inventory 06:52 Transportation 07:...
Only Use Inheritance If You Want Both of These
Просмотров 12 тыс.14 дней назад
Inheritance gives us hierarchical reuse of code AND subtype polymorphism. In this video I argue that we should only ever use it if we want BOTH. patreon.com/christopherokhravi 📚 Recommended Reading: geni.us/nlbA6 (Head First: Design Patterns) geni.us/PsXmo (Design Patterns: Elements of Reusable Object-Oriented Software) Watch next: ruclips.net/video/YaSMkzmc_sA/видео.html ruclips.net/video/TkUh...
7 Tips to Grow as a Developer
Просмотров 14 тыс.21 день назад
I meet many programming students. Here are 7 opportunities to grow that I see time and time again. 🙌 patreon.com/christopherokhravi Books and talks from mentors that have shaped the way I think: SANDI METZ ⚙️ geni.us/APcJLnI (Practical Object-Oriented Design) ruclips.net/video/OMPfEXIlTVE/видео.html (Nothing is Something) MARTIN KLEPPMANN 🏛️ geni.us/Pj6IS4U (Designing Data-Intensive Application...
Depend on Abstractions not Concretions (Framework)
Просмотров 14 тыс.Месяц назад
I made this simple framework to explain why and how we should "depend on abstractions and not on concretions". It's a quadrant diagram where the two dimensions captures the principles "program to interfaces, not implementations" and "dependency injection". 🏛️ geni.us/IBhtLnh (Clean Architecture) 🧠 geni.us/CpLx2y (Agile Principles, Patterns, and Practices) 🌟 geni.us/zzlx (Dependency Injection: P...
3 Reasons WHY Waterfall Doesn't Work
Просмотров 4,5 тыс.Месяц назад
Three simple models that explain why and when the Waterfall method cannot work. 🎓 References: - geni.us/1obVBO [Rubin, K. S. (2012). Essential Scrum: A practical guide to the most popular Agile process. Addison-Wesley., Fig. 3.7] - users.ece.utexas.edu/~perry/education/SE-Intro/lehman.pdf [Lehman, M. M. (1980). Programs, life cycles, and laws of software evolution. Proceedings of the IEEE, 68(9...
They Knew Waterfall Didn't Work
Просмотров 13 тыс.Месяц назад
Did you know that the paper that introduced the Waterfall method said that it is "risky and invites failure". They knew it didn't work. ⚠️ Watch next: ruclips.net/video/yhwaisT0VTM/видео.html 🌟 Join the Patreon www.patreon.com/christopherokhravi 📚 Recommended Reading: geni.us/1obVBO (Essential Scrum) 📜 Royce, Winston. (1970). Managing the development of large software systems. blog.jbrains.ca/a...
Always Use Interfaces
Просмотров 43 тыс.Месяц назад
How to follow the principle of Couple To Abstractions, Not Concretions, and how to avoid tempting others to break the rule. 🎓 Get the book: geni.us/hNDE Watch before: ruclips.net/video/YaSMkzmc_sA/видео.html Watch next: ruclips.net/video/SeN1s65tRHY/видео.html FURTHER RECOMMENDED READING: - geni.us/zzlx (Dependency Injection: Principles, Practices, and Patterns) - geni.us/IBhtLnh (Clean Archite...
Understanding Covariance and Contravariance
Просмотров 10 тыс.Месяц назад
The intuition behind Covariance and Contravariance explained with 🍎, oranges 🍊, and cats 🐈. 00:00 Question 00:41 Fruit example (Covariance) 01:14 Fruit example (Contravariance) 02:03 UML (Covariance) 03:24 UML (Contravariance) 04:53 Formal definitions 06:12 Type safety 07:16 Robustness Principle 08:20 Invariant list (Covariance) 09:43 Invariant list (Contravariance) 10:59 Invariant list (summar...
3 Ideas on Refactoring by Martin Fowler
Просмотров 19 тыс.2 месяца назад
Nuggets from one of the most iconic programming books of all time. 🔥 Get the book! geni.us/k8KhT3 ▶️ Watch this next: ruclips.net/video/v9ejT8FO-7I/видео.htmlsi=G4rUIATVohCU_lwM 00:00 Intro 00:09 Idea 1 01:27 Idea 2 03:27 Book 03:46 Idea 3 05:40 Outro
The Square-Rectangle Problem
Просмотров 9 тыс.2 месяца назад
The Square-Rectangle Problem
The Only Time You Should Use Polymorphism
Просмотров 85 тыс.2 месяца назад
The Only Time You Should Use Polymorphism
Object Oriented Programming - Lecture 2 - Paradigms, Types, Compilation, Purity, Programs
Просмотров 41 тыс.3 года назад
Object Oriented Programming - Lecture 2 - Paradigms, Types, Compilation, Purity, Programs
Object Oriented Programming - Lecture 1 - Overview of contents
Просмотров 27 тыс.3 года назад
Object Oriented Programming - Lecture 1 - Overview of contents
My Vim Setup #2 (Mappings / Custom shortcuts)
Просмотров 38 тыс.5 лет назад
My Vim Setup #2 (Mappings / Custom shortcuts)
My Vim Setup #1 (Job Control)
Просмотров 41 тыс.5 лет назад
My Vim Setup #1 (Job Control)
Reactive Programming from Scratch (JavaScript) - Ep3
Просмотров 6 тыс.5 лет назад
Reactive Programming from Scratch (JavaScript) - Ep3
Reactive Programming from Scratch (JavaScript) - Ep2
Просмотров 6 тыс.5 лет назад
Reactive Programming from Scratch (JavaScript) - Ep2
Reactive Programming from Scratch (JavaScript) - Ep1
Просмотров 29 тыс.5 лет назад
Reactive Programming from Scratch (JavaScript) - Ep1
(Ep2) Mandala Maker in JavaScript (functional style)
Просмотров 2,2 тыс.5 лет назад
(Ep2) Mandala Maker in JavaScript (functional style)
(Ep1) Mandala Maker in JavaScript (functional style)
Просмотров 3,7 тыс.5 лет назад
(Ep1) Mandala Maker in JavaScript (functional style)
Ramda JS Tutorial - Part 40 (filter)
Просмотров 2,4 тыс.5 лет назад
Ramda JS Tutorial - Part 40 (filter)
Todo App in Vue.js - The Hard Way (Ep18)
Просмотров 3,1 тыс.5 лет назад
Todo App in Vue.js - The Hard Way (Ep18)
Todo App in Vue.js - The Hard Way (Ep17)
Просмотров 1,8 тыс.5 лет назад
Todo App in Vue.js - The Hard Way (Ep17)
Vue.js - The Hard Way (Ep16)
Просмотров 1,5 тыс.5 лет назад
Vue.js - The Hard Way (Ep16)
Vue.js - The Hard Way (Ep15)
Просмотров 1,7 тыс.5 лет назад
Vue.js - The Hard Way (Ep15)
Vue.js - The Hard Way (Ep14)
Просмотров 1 тыс.5 лет назад
Vue.js - The Hard Way (Ep14)
Vue.js - The Hard Way (Ep13)
Просмотров 1,2 тыс.5 лет назад
Vue.js - The Hard Way (Ep13)
Ramda JS Tutorial - Part 39 (T, F)
Просмотров 1 тыс.5 лет назад
Ramda JS Tutorial - Part 39 (T, F)
Vue.js - The Hard Way (Ep12)
Просмотров 1,4 тыс.5 лет назад
Vue.js - The Hard Way (Ep12)

Комментарии

  • @Amrmohamed-us3dw
    @Amrmohamed-us3dw 17 часов назад

    What a great content from an incredible instructor❤❤

  • @arastusharma439
    @arastusharma439 19 часов назад

    Loved it!! This man energy is unmatchable !!

  • @burrillgray4812
    @burrillgray4812 19 часов назад

    I think it was a helpful video. Succinct and to the point. Good job!

  • @janvanwijk5979
    @janvanwijk5979 20 часов назад

    Another excellent video, thanks for making it! ❤

  • @user-ev9jg6ts6e
    @user-ev9jg6ts6e 2 дня назад

    Excellent as always. How soon will you publish your own book?)

    • @ChristopherOkhravi
      @ChristopherOkhravi 4 часа назад

      It's already 'published' 😊 I wrote a book on OOP and it's currently available for free at theobjectorientedway.com. It moves from the very basics (like variables) to fairly advanced concepts (like variance in generic interfaces). Thanks for asking 😊

    • @user-ev9jg6ts6e
      @user-ev9jg6ts6e 4 часа назад

      @@ChristopherOkhravi Wow, wonderful) I'll take a look) Thanks.

    • @user-ev9jg6ts6e
      @user-ev9jg6ts6e 4 часа назад

      @@ChristopherOkhravi Do you have a PDF of the book?

  • @lavanyam3224
    @lavanyam3224 2 дня назад

    Your explanation is lit ❤ I read the book explanation after your video and it made so much sense! You made it so easy ;)

  • @FritsvanDoorn
    @FritsvanDoorn 2 дня назад

    You make this difficult subject easy to understand. Thank you.

  • @jussiheino
    @jussiheino 2 дня назад

    Here's my invariant: sometimes I'd like to give a bigger thumbs-up than others. This is a good lesson! Worth re-uploading the corrected version, good stuff, can recommend.

  • @nullset11
    @nullset11 3 дня назад

    How many attempts at the orange juggle before camera perfect? 😄

  • @harshkuddu4386
    @harshkuddu4386 3 дня назад

    Bro I been saying this for years, no way.

  • @kumarchandan6336
    @kumarchandan6336 3 дня назад

    I have cracked Low Level Design interviews in companies like Microsoft, Amazon, Atlassian, Flipkart, etc with the help of your videos. Your videos are really helpful. Keep up the good work.

    • @ChristopherOkhravi
      @ChristopherOkhravi День назад

      Wow. I’m happy to hear that! Thanks for sharing. 🙏😊 And congratulations!

  • @KhakiShow
    @KhakiShow 4 дня назад

    2024, saving lives.

  • @ajzack983
    @ajzack983 4 дня назад

    Liberal is weaker, conservative is stronger. Got it.

  • @devid6799
    @devid6799 4 дня назад

    Greetings from Germany. I love you!

  • @albertwang5974
    @albertwang5974 5 дней назад

    Be a nice guy, and don't expect every one will be a nice guy!

  • @albertwang5974
    @albertwang5974 5 дней назад

    Don't be a trouble maker, and don't fail if you have to work with a trouble maker!

  • @arastusharma439
    @arastusharma439 5 дней назад

    Pure Majic in Explanation !! Didn't realise the time while watching it and it seems like just now started.Thankyou for such good content!

  • @alejandroioio6784
    @alejandroioio6784 5 дней назад

    😎

  • @Silverflame1
    @Silverflame1 5 дней назад

    You can also find a lot of information about the problem of subtyping if you look up "Circle-ellipse problem".

  • @miguelcerne1150
    @miguelcerne1150 5 дней назад

    The first Design Patterns Series that really simplifies and doesn't overcomplicates the basics! You're the best, keep up with the channel please!

  • @Wojmasz
    @Wojmasz 5 дней назад

    great piece of knowledge! thank you!

  • @johncerpa3782
    @johncerpa3782 5 дней назад

    Great video, thank u

  • @patrickstephen7885
    @patrickstephen7885 6 дней назад

    Your content is amazing. Great stuff

  • @waleedelwakeel5721
    @waleedelwakeel5721 6 дней назад

    That's amazing. I am always eager to understand pure concepts rather technology coupled ones. I appreciate your interest in that matter and you are truly killing it. Thank you for your efforts and I hope you continue sharing your great knowledge.

  • @javiermorin3110
    @javiermorin3110 6 дней назад

    I love all your videos! Thank you so much for taking the time to make them!

  • @tibrec8
    @tibrec8 6 дней назад

    nice as always bro , can make technical practice video for this .

    • @ChristopherOkhravi
      @ChristopherOkhravi День назад

      Thank you for the feedback. I will think about how to make my content more concrete in the future. Screencasts is a very saturated niche so I’m very hesitant towards entering that game again 😊

  • @bogdanf6698
    @bogdanf6698 6 дней назад

    comment for support! thanks! I'll get back here in 2 years :D after I have learned enough to understand the explication

  • @MarkMifsud
    @MarkMifsud 6 дней назад

    Your explanations are long winded, but they are clear and that's why they are really helpful. Thanks.

    • @ChristopherOkhravi
      @ChristopherOkhravi 6 дней назад

      Please do let me know if you start to think that I'm becoming way too repetitive 😊 Thank you for watching and for the feedback 😊🙏

    • @michaelhaddad2190
      @michaelhaddad2190 5 дней назад

      @@ChristopherOkhravi Absolutly not. Every second of every video is gold.

  • @wilkesreid
    @wilkesreid 6 дней назад

    This seems kind of obvious to me. If B is a subclass of A and “x” is an instance of some subclass of A, and you could have x.fido() calls anywhere, then it would be utter chaos because x could be an instance of B in any of those places and B could have overridden fido to behave so differently that your code can’t know what to expect as a result of x.fido() because it could be anything. If I expect x.fido() to return an array, then an array of objects, or array of ints is fine, but of course you shouldn’t override it to return an object or some struct. And if the arguments given to x.fido() could be any integer, then of course you shouldn’t reject whatever would normally be acceptable to A for that method.

  • @demarcorr
    @demarcorr 6 дней назад

    covariance and contravariance are probably one of those things i understand subconsciously but can never seem wrap my head around consciously

  • @amerbashoeb2106
    @amerbashoeb2106 6 дней назад

    Thank you!

  • @detaaditya6237
    @detaaditya6237 6 дней назад

    Wow I never thought Postel's Law is related with LSP. It makes a lot of sense, though!

  • @ReviewSutras
    @ReviewSutras 6 дней назад

    Can we have examples?

    • @ChristopherOkhravi
      @ChristopherOkhravi День назад

      Thank you for the question and for the feedback. Would it be possible to elaborate a bit? I give examples in the sections on Terminology (8:50) and Behavioral rules (11:59). But it seems that you are looking for something else. Thanks again for the feedback and for watching 😊😊

    • @ReviewSutras
      @ReviewSutras День назад

      @@ChristopherOkhravi Thanks for your response. Example in the sense, with a sample class in java, we try to see things in action.

  • @felipecardoso3142
    @felipecardoso3142 6 дней назад

    Great explanation indeed, but the remaining question is: When will you instantiate the objects? This has to happen somewhere, right? One cannot have infinite levels of abstraction...

    • @ChristopherOkhravi
      @ChristopherOkhravi День назад

      The short answer is: in Main and in Factories. The long answer is that i will try to address this in a future video 😊😊 Thank you very much for watching and for asking 😊🙏

  • @nullcheque
    @nullcheque 6 дней назад

    Before I even finish this video-big thank you for the Elegant Objects recommendation in your other video about Always Using Interfaces. I am about halfway through the book, and in conjunction with your content about coupling to abstractions, my understanding and use of OOP has already begun greatly improving the code I write at work.

    • @ChristopherOkhravi
      @ChristopherOkhravi 6 дней назад

      Happy to hear 😊 Thanks for letting me know 😊🙏

  • @wjrasmussen666
    @wjrasmussen666 6 дней назад

    Bag of fruit has apples, bananas, grapes, oranges.....

  • @greob
    @greob 6 дней назад

    Very nice presentation, easy to follow and understand. Thanks for sharing!

  • @mortenbork6249
    @mortenbork6249 6 дней назад

    If you use composition over inheritance, and DI with interfaces, and not types. You can't violate LSP, because the rules are inherently followed. This is actually one of the reasons that composition is better than inheritance.

    • @Robert-yw5ms
      @Robert-yw5ms 6 дней назад

      This is wrong. Every interface exposes a contract. When you implement that interface, you have to fulfill that contract. Otherwise you're breaking the lsp. Example you have an interface IStack with the normal stack methods and you then implement it in a FIFO way. You've just broken lsp.

    • @TuxCommander
      @TuxCommander 6 дней назад

      Wrong. You literally ignoring the fundamental aspect of LSP. As stated in the video, it's mainly about behaviour not design which would be detected by the compiler.

    • @mortenbork6249
      @mortenbork6249 6 дней назад

      ​@@Robert-yw5ms And your compiler will prevent you from not fulfilling the contract. You can't break it.

    • @Robert-yw5ms
      @Robert-yw5ms 5 дней назад

      @@mortenbork6249 It won't prevent you from breaking the behavioural contract. Read the example I gave and try to understand it.

    • @Robert-yw5ms
      @Robert-yw5ms 5 дней назад

      @@mortenbork6249 Type definitions are only one part of the contract. Behaviour is the other. Read the example I gave and try to understand it. Or watc the video from 12 minutes. Each interface promises to have certain preconditions, post conditions and invariants.

  • @grossd18
    @grossd18 6 дней назад

    Can it be worthwhile to apply these principles to interface evolution, when a need for backwards compatibility is desireable. It seems that yes, it could apply.

  • @peteralexandre6593
    @peteralexandre6593 6 дней назад

    Thanks for this amazing content. It might be dumb to ask but being a non native english speaker what is this word you are using in a lot of your videos wich sounds like "hirokee" ? Need to know how to spell it to search for the definition 😅

    • @ChristopherOkhravi
      @ChristopherOkhravi 6 дней назад

      I think you are referring to “hierarchy”, no? Do note that all my new videos have accurate closed captions. So be sure to turn those on if you find the way I speak confusing. Which is understandable since I’m not a native English speaker either 😊😊😊 Thank you for watching and for asking. 😊🙏

    • @peteralexandre6593
      @peteralexandre6593 6 дней назад

      Yeah that's hierarchy thank you so much. No no your English accent is perfect I understand 99% of your videos even without captions it's just that I was not used to the word hierarchy in English. See, you make me a better developer and make me improve my English at the same time. Thanks again.😊

  • @PixelSergey
    @PixelSergey 6 дней назад

    Interesting! How would one implement classes such as UniqueList or ImmutableList while still following these principles? It seems so natural to just write a bunch of code for a base List class, and then just make a subclass that inherits this code but adds extra checks (for immutability or uniqueness). How do we do this in other ways?

    • @Robert-yw5ms
      @Robert-yw5ms 5 дней назад

      Simple: don't inherit from list. But there's nothing stopping you using a list as a backing field

  • @silberwolfSR71
    @silberwolfSR71 6 дней назад

    Amazing video as usual! I think an interesting thing to point out is that many of these different "software design principles" complement each other, each making use of the others easier and more effective. For instance, preferring to code to interfaces makes adhering to the Liskov Substitution Principle much easier, because there are usually no invariants relating to state. Similarly, interface segregation leads to small interfaces, whose invariants are easier to grasp and enforce. Sharing code through composition rather than inheritance bypasses substitution concerns entirely, since there's no subtyping involved.

    • @ChristopherOkhravi
      @ChristopherOkhravi 6 дней назад

      Indeed. I very much agree. Thanks for pointing this out 😊🙏 And thanks for watching 😊

  • @filippobuonco95
    @filippobuonco95 6 дней назад

    Lovely! Thanks for this video! I have a question, is a violation of the LP if a method in the subclass accept more parameters (meaning not a bigger range of values of the parameter, but really the number of parameters the method is getting as input) than the method in the superclass?

    • @ChristopherOkhravi
      @ChristopherOkhravi 6 дней назад

      Thank you for the detailed question. In my reading I would say that more parameters is not a violation as long as it still can be called just like you can call the super class. So the additional parameters would have to be optional for this to work. Otherwise this is actually not being liberal but rather being conservative. Off the top of my head I cannot however think of languages that would support this. Did you have some language or example in mind? Thank you again 😊🙏

    • @Robert-yw5ms
      @Robert-yw5ms 6 дней назад

      @@ChristopherOkhravi Javascript supports this without issue. class Parent { foo(x) { console.log(x) } } class Child extends Parent { foo(x,y) { console.log(x,y) } } new Child().foo(1,2); Although in a sense the parent foo method will also accept any number of arguments. It'll just ignore the extra ones. It will also accept fewer parameters and treat x as undefined. I'd also say that adding overloads with different parameter counts in c# or java is another example. Which clearly doesn't break LSP.

    • @ChristopherOkhravi
      @ChristopherOkhravi 6 дней назад

      @@Robert-yw5ms Silly of me to not immediately think of JavaScript 😊😊Thank you for the reply. Overloading however does not need to respect LSP. LSP applies when we are overriding, or more generally: when we have dynamic dispatch as a consequence of subtype polymorphism. So in other words, interface implementation (in languages like C# and Java) also needs to respect LSP.

    • @Robert-yw5ms
      @Robert-yw5ms 6 дней назад

      ​@@ChristopherOkhravi Although it is worth noting that this is one of many issues with javascript that typescript fixes. I hope people don't read my comment and think "oh amazing let's do that" :D And I agree completely with your second paragraph.

  • @pixaz
    @pixaz 6 дней назад

    14:33 the same argument could be made when you say same or weaker precondition. If we have a base type of UniqueListBase with a precondition, on the Add method that you cannot add duplicates, and subtype of UniqueListDerived that isnt restricting the uniqueness. That would also be a violation of liskov no? if somewhere down the road, people are using UniqueListDerived as a UniqueList, it might cause them problem

    • @ChristopherOkhravi
      @ChristopherOkhravi 6 дней назад

      I think I understand what you mean but tell me if it seems like I don’t. According to LSP, the example you give would not be a violation. It is ok to make preconditions weaker. So if the subtype wants to get rid of the requirement that we cannot add items that are already in the list that would be perfectly fine. If you however have a postcondition or an invariant that says that items may not be duplicated in the list then that cannot be weakened in the subtype. And if your base type is called UniqueList then it would (imho) make sense for us to think of it as having postconditions or invariants enforcing uniqueness of elements. Makes sense? Thanks for the detailed comment and for watching 😊🙏

    • @pixaz
      @pixaz 6 дней назад

      @@ChristopherOkhravi oh i seeee! thanks for the response!

  • @RobertShresthawolf
    @RobertShresthawolf 6 дней назад

    First one here :)

  • @Luuncho
    @Luuncho 7 дней назад

    I love lean

  • @bunglegrind1
    @bunglegrind1 7 дней назад

    An enlightening reading is smalltak objects and design by chaimond liu, chapter 17. The problem with class inheritance is that it allows method overrides, which in practice violate LSP. If the instances are read-only you don't override get/set and LSP is satisfied

  • @kirilmicev843
    @kirilmicev843 7 дней назад

    I think this MUDA concept will have very big acceptance in Serbia.

  • @alejandroioio6784
    @alejandroioio6784 7 дней назад

    😎

  • @alejandroioio6784
    @alejandroioio6784 7 дней назад

    😎