GRASP Design Principles: Why They Matter (And How to Use Them)

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 มิ.ย. 2024
  • In this video, I'll dive into the GRASP design principles and explore why they matter when designing software systems. By understanding these principles, you'll be able to write better code that's easier to maintain and extend.
    Example code: github.com/ArjanCodes/2023-grasp.
    🚀 Next-Level Python Skillshare Class: skl.sh/3ZQkUEN
    👷 Join the FREE Code Diagnosis Workshop to help you review code more effectively using my 3-Factor Diagnosis Framework: www.arjancodes.com/diagnosis
    💻 ArjanCodes Blog: www.arjancodes.com/blog
    🎓 Courses:
    The Software Designer Mindset: www.arjancodes.com/mindset
    The Software Designer Mindset Team Packages: www.arjancodes.com/sas
    The Software Architect Mindset: Pre-register now! www.arjancodes.com/architect
    Next Level Python: Become a Python Expert: www.arjancodes.com/next-level...
    The 30-Day Design Challenge: www.arjancodes.com/30ddc
    🛒 GEAR & RECOMMENDED BOOKS: kit.co/arjancodes.
    👍 If you enjoyed this content, give this video a like. If you want to watch more of my upcoming videos, consider subscribing to my channel!
    💬 Discord: discord.arjan.codes
    🐦Twitter: / arjancodes
    🌍LinkedIn: / arjancodes
    🕵Facebook: / arjancodes
    📱Instagram: / arjancodes
    ♪ Tiktok: / arjancodes
    👀 Code reviewers:
    - Yoriz
    - Ryan Laursen
    - James Dooley
    - Dale Hagglund
    🎥 Video edited by Mark Bacskai: / bacskaimark
    💻 Code example by Henrique Branco: / henriqueajnb
    🔖 Chapters:
    0:00 Intro
    0:59 Overview
    1:23 01 - Creator
    4:28 02 - Information expert
    7:39 03 - Controller
    11:57 04 - Protected variations
    14:58 05 - Indirection
    17:34 06 - Low coupling
    20:43 07 - High cohesion
    24:26 08 - Polymorphism
    28:43 09 - Pure fabrication
    30:07 Retrospective
    31:44 Outro
    #arjancodes #softwaredesign #python
    DISCLAIMER - The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you. Thanks for supporting my channel so I can continue to provide you with free content each week!

ความคิดเห็น • 75

  • @ArjanCodes
    @ArjanCodes  8 หลายเดือนก่อน +1

    👷 Join the FREE Code Diagnosis Workshop to help you review code more effectively using my 3-Factor Diagnosis Framework: www.arjancodes.com/diagnosis

  • @johncrunk8038
    @johncrunk8038 ปีที่แล้ว +61

    I feel like I was drinking from the firehose. A whole semester of CS in one video. This one will require many visits. Bravo.

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว +1

      Thank you so much John!

    • @AWhite_
      @AWhite_ ปีที่แล้ว

      That's true...😅😅

  • @awaitingforsunrise
    @awaitingforsunrise ปีที่แล้ว +4

    The best GRASP-related video on TH-cam! I traversed more than 20 ones in order to watch practical examples rather than clumsy theoretical declarations scraped from Wikipedia, which makes things even more unclear.
    Your channel is a pure diamond and I'll stick for here later, because there is a lot of PRACTICAL information. Even despite on I'm Java-developer. Keep going! Thank you.
    Will share it to friends and mates as a good example of how the things should be practically explained.

  • @vbaclasses3553
    @vbaclasses3553 ปีที่แล้ว +3

    My first time encountering GRASP. Now all the previous videos makes sense. Thank you for sharing.

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      You're very welcome!

  • @Ledinos1
    @Ledinos1 ปีที่แล้ว +12

    As always very valuable material. Thanks Arjan :)

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Glad you think so!

  • @adiliqbalc9075
    @adiliqbalc9075 ปีที่แล้ว +2

    Please do an individual video for each principle. That way we get a rock solid idea of the principle. Thanks!

  • @mpfmorawski
    @mpfmorawski ปีที่แล้ว +9

    Great and comprehensive material, again! I feel that with each of your videos the quality of my software development in Python increases :D Thank you!

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Glad to hear it helps you!

  • @AlexRodriguez-vl1ec
    @AlexRodriguez-vl1ec ปีที่แล้ว +3

    Loving the Content! Keep it up! Also looking forward to more Code Roasts! 👍 🙏🙏

  • @AAZinvicto
    @AAZinvicto ปีที่แล้ว

    I am happy when someone talks about GRASP principles.
    They not only tell what is the ideal design of the code, but also how to achieve that ideal state.

  • @Skibadee99
    @Skibadee99 ปีที่แล้ว +4

    Thanks!

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Thank you so much!

  • @Polynook
    @Polynook ปีที่แล้ว

    Great content. Keep it up!

  • @deeplazydev
    @deeplazydev ปีที่แล้ว +1

    I appreciate you use classes. In engineering software we are not using functions (far away more complex code than what is generally shown in youtube).

  • @togrulasadov6709
    @togrulasadov6709 ปีที่แล้ว +2

    Well done sir. Your videos are ones I like before proceeding to watch.

  • @federicomuciaccia9191
    @federicomuciaccia9191 ปีที่แล้ว +2

    I think you should show the functional way more often (every time it is applicable). it is very useful (and the TH-cam videos about that way to do things are not that many...)

  • @kevon217
    @kevon217 ปีที่แล้ว +1

    Great video as always!

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      I appreciate that!

  • @gonzaloplazag
    @gonzaloplazag ปีที่แล้ว

    Great video as usual! Thanks!

  • @wesleycesar6915
    @wesleycesar6915 ปีที่แล้ว

    Greet video, tnk foi this

  • @chrisweldon791
    @chrisweldon791 ปีที่แล้ว

    Invaluable. Thank you.

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Thank you - glad you found it valuable!

  • @SP-db6sh
    @SP-db6sh ปีที่แล้ว +4

    1.4k views but 129 likes still now... Ridiculous sence of gratitude!
    Respected, sir 🖖
    Your content is Rare star in the universe of coding guru's🌠🌟
    🎉🎀
    Thank you for your continuous 🎁
    Love from gratitude from🇮🇳

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      Thank you so much SP!

  • @Golgafrincham
    @Golgafrincham ปีที่แล้ว +3

    Really good video as usual! You are basically the reason for me staying on top of our Python-related challenges at work :D

  • @shizueigaki702
    @shizueigaki702 10 หลายเดือนก่อน

    I will make all my coworkers watch this, cause OHMYGOD some people just need to. Thank you so much, Arjan, for this.

    • @ArjanCodes
      @ArjanCodes  10 หลายเดือนก่อน +1

      Thank you so much!

  • @fabricehategekimana5350
    @fabricehategekimana5350 7 หลายเดือนก่อน

    Thank you for this great video ! TBH the liskov substitution talk more about type than class. In OOP we generally only have classes to define new types so it's mainly about inheritance but it's also possible in FP (especially with algebraic data types)

  • @astronemir
    @astronemir ปีที่แล้ว +1

    I love the vehicle video

  • @SubZeRoy9
    @SubZeRoy9 ปีที่แล้ว

    Final today. One of the topics is grasp. Wish me luck.

  • @chriswunder5420
    @chriswunder5420 ปีที่แล้ว

    Thanks, I enjoyed the video.
    I think it would be better to let the view call the controller, since in your example the controller is basically the whole use case of the application, thus should not be dependent on view (DI). Also then you can add several views calling the controller without ever changing the controller (OCP). Although these suggestions come from a SOLID perspective.

  • @terrelbs
    @terrelbs ปีที่แล้ว

    great videos. really.

  • @djl3009
    @djl3009 ปีที่แล้ว

    Not sure what I found more useful in that book "Applying UML And Patterns" -- the design advice with examples, the GRASP principles or the quotes at the start of each chapter. Quotes like, "Le mieux est l'ennemi du bien (The best is the enemy of the good). -- Voltaire"

  • @ShanilPanara
    @ShanilPanara ปีที่แล้ว

    Great video, as always! You talk a lot about how you'd do lots of functional programming rather than object oriented programming... I'd love to see a video where you compare pure functional, pure object oriented, and a mix of both :) possibly doing the same thing?

    • @ShanilPanara
      @ShanilPanara ปีที่แล้ว

      Haha, I hadn't quite finished the video yet

  • @user-vh8bm3fw9w
    @user-vh8bm3fw9w ปีที่แล้ว

    I've read about them a long time ago. Thanks for your work. Maybe you will be so nice as to cover something form Eric Evans' book. There is a lot of interesting and useful information there, but it may be a bit complicated.

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      I'll check it out! Thanks

  • @TheScriptPunk
    @TheScriptPunk ปีที่แล้ว

    Food for thought, each line of code should be responsible for one thing.
    Or blocks of lines.
    So, each line/block is a step. A singular step that does one thing.

  • @edgeeffect
    @edgeeffect ปีที่แล้ว

    Some of these highlight certain circumstances where SOLID doesn't apply... and, therefore, deepen our understanding of SOLID.... or other sets of principles/patterns.

  • @doniyorturemuratov6999
    @doniyorturemuratov6999 ปีที่แล้ว

    Awesome as usual!. I didn't receive the email once I enrolled in Code Diagnosis Workshop.

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว +1

      Sometimes issues can occur and in this case the best you can do is to send an email to support@arjancodes.com

  • @anvicom
    @anvicom 6 หลายเดือนก่อน

    What VS Code extension do you use to auto complete the code. I see that as you type suddenly the code lines appears from nowhere

  • @_DRMR_
    @_DRMR_ ปีที่แล้ว

    So what if the behavior of your processing is highly dependent on the data structure?
    I'm really interested to hear your ideas around recursive algorithms. What kind of design principles are best suited to accommodate such data processing?

    • @teeesen
      @teeesen ปีที่แล้ว

      There’s a principle that Arjan didn’t mention which is to anticipate change. In the case of tree shaped data, the code can evolve by adding more kinds of trees or by adding more procedures that operate on trees. For example if you represent documents with trees the code might evolve to add more kinds of node, e.g., enumerated lists and description lists as well as bullet lists, or it might evolve to add more recursive algorithms on the trees, e.g., convert to PDF and serialize, as well as layout. When you expect the set of kinds of node to expand but the number of algorithms to be essentially fixed, it makes sense to just implement each algorithm with a method that has a separate implementation in each node class, e.g. bullet list has its implementation of layout, and then so does description list and enumerated list. On the other hand, if the set of kinds of nodes is relatively stable, you can just write each recursive algorithm as a single recursive procedure with a switch (or match) statement at the top level. If change is likely along both axes, I don’t know of a magic solution.

  • @Isa-oo8mz
    @Isa-oo8mz ปีที่แล้ว

    Doesn't the creator principle violate the DI principle of solid? Because in add_line_item function you use class Salelineitem directly.

  • @bijeshmohan
    @bijeshmohan ปีที่แล้ว

    It would be better if this was a Playlist of videos

  • @tugrulpinar16
    @tugrulpinar16 ปีที่แล้ว

    20:39 - I think CreditCard class should inherit PaymentMethod class just like Cash class did.

  • @Jack9C
    @Jack9C ปีที่แล้ว +1

    I tend to have a lot of problems with principles, but the creator pattern example is particularly problematic. ie Sale(...) knowing how to create SaleLineItems. Why would you store the creation in the class, which you now have to move if:
    1. your language class access modifiers make nesting class creation a problem for testability. In most languages, I can't mock the object creation nested in another class.
    2. you want to be able to create SaleLineItems later
    Following the Creator pattern, an author would aschew placing a creator solely in another class as a matter of code quality due to the obvious advantages of DI.

    • @peterlinddk
      @peterlinddk ปีที่แล้ว

      The Creator principle doesn't prohibit or prevent you from creating new objects from classes elsewhere, it merely suggests where it would be best to do it in your program. SaleLineItems aren't nested inside Sale class - they are just created (instantiated) there. You can always create a SaleLineItem outside of Sale if you want to - but you shouldn't need to.

  • @TankaNafaka
    @TankaNafaka ปีที่แล้ว

    I hate oo patterns, but always nice to hear you explaining stuff.
    btw: as per ifnotelse and switch blocks which leads to imperative programming, use declarative approach with protocol class as you explained

  • @EW-mb1ih
    @EW-mb1ih ปีที่แล้ว

    at 19:42, why does Cash class inherits from PaymentMethod whereas CreditCard doesn't?

    • @harrisonfleisher3772
      @harrisonfleisher3772 ปีที่แล้ว

      He forgot is all. CreditCard was supposed to inherit from PaymentMethod.

  • @davidmatten8519
    @davidmatten8519 9 หลายเดือนก่อน

    someone must have redefined what acronyms are, and not told me. Now they don't have to contain any of the first characters of any of the constituent terms!

  • @appuser
    @appuser ปีที่แล้ว +1

    "and I will try not to making any stupid puns".
    Yes, because you don't need to "try". They come just come out 😉

    • @ArjanCodes
      @ArjanCodes  ปีที่แล้ว

      I can’t control myself 😊

  • @arentstienstra8614
    @arentstienstra8614 ปีที่แล้ว +1

    WTF, None the letters in GRASP map to the concept that they describe

  • @jorgeluisriosportilla1617
    @jorgeluisriosportilla1617 ปีที่แล้ว +4

    Please more examples with only functions. I would even refactor your old videos with a light SOLID or now with a functional GRASP video that pays attention to the power of a simpler Python without classes. Please. Thanks.

  • @akramomari547
    @akramomari547 8 หลายเดือนก่อน

    i love this video (INDIAN ACCENT)

  • @edgeeffect
    @edgeeffect ปีที่แล้ว

    Awww.... I wanted stupid puns :)

  • @study_vandanrevanur
    @study_vandanrevanur หลายเดือนก่อน

    Nine principles of GRASP
    1 - Creator
    2 - Information Expert
    3 - Controller
    4 - Protected Variations
    5 - Indirection
    6 - Low Coupling
    7 - High Cohesion
    8 - Polymorphism
    9 - Pure Fabrication

  • @kicknotes
    @kicknotes ปีที่แล้ว +2

    Side note: Anyone old enough to remember when GRASP meant .GL files?

  • @sundeepanand-zs7gm
    @sundeepanand-zs7gm ปีที่แล้ว

    Thanks!