Apply the GRASP Design Principles to Improve Your Python Code

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

КОМЕНТАРІ • 71

  • @ArjanCodes
    @ArjanCodes  11 місяців тому +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 Рік тому +62

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

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

  • @Ledinos1
    @Ledinos1 Рік тому +12

    As always very valuable material. Thanks Arjan :)

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

  • @adiliqbalc9075
    @adiliqbalc9075 Рік тому +2

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

  • @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 UA-cam videos about that way to do things are not that many...)

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

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

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

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

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

    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)

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

    Great video as always!

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

    Great video as usual! Thanks!

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

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

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

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

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

    I love the vehicle video

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

    Invaluable. Thank you.

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

      Thank you - glad you found it valuable!

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

    Great content. Keep it up!

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

    Greet video, tnk foi this

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

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

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

  • @sundeepanand-zs7gm
    @sundeepanand-zs7gm Рік тому

    Thanks!

  • @ЕвгенийИванов-ю2б

    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.

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

    great videos. really.

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

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

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

    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

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

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

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

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

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

    It would be better if this was a Playlist of videos

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

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

    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 😉

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

    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

  • @akramomari547
    @akramomari547 11 місяців тому

    i love this video (INDIAN ACCENT)

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

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

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

    Awww.... I wanted stupid puns :)

  • @kicknotes
    @kicknotes Рік тому +2

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