D in SOLID - I wish I learned the LAST letter FIRST

Sdílet
Vložit
  • čas přidán 29. 08. 2024

Komentáře • 81

  • @git-amend
    @git-amend  Před 8 měsíci +9

    Hi everyone, Happy Holidays! This video should answer some of questions about the D in SOLID (and coupling). If you have more questions about SOLID, or architecture in general, please post in the comments to help me plan videos for 2024!
    More code has been added for Extension methods and Dependency Injection!
    github.com/adammyhre/Unity-Dependency-Injection-Lite
    github.com/adammyhre/Unity-Utils

  • @Chronomatrix
    @Chronomatrix Před 8 měsíci +22

    Finally a channel that properly explains game development from a software architecture perspective. I seriously struggled whenever my games would start going beyond the basic prototypes you get to do when following online courses. This last year I've been focusing on learning software architecture and design patterns and my perspective completely changed. Now I finally feel like I can deal with bigger projects. Btw I highly recommend learning UML representation, it's a great tool to design games without the need to write a single line of code.

    • @git-amend
      @git-amend  Před 8 měsíci +2

      Thanks for the comment! UML is a great tool, I use it often when designing or documenting systems. In the most recent video I touch on using AI with plantUML at the end of the video. Cheers!

    • @9rrr7
      @9rrr7 Před 7 měsíci +4

      Can't agree more... As an experienced developer, when I first started cracking Unity, I was amaized to learn that community lacks good software development topics online... It's been long time ago, and I already have my ideas about good Unity software practices and was hoping to crate a channel talking about my ideas but unfortunately never had a chance to do so because of my full time job😞
      But it is great to see that at least someone started to talk about it!!! Finally, I can evaluate my ideas against other's!!

  • @stickguy9109
    @stickguy9109 Před 8 měsíci +23

    So how many patterns do you want to use?
    git-amend: yes

    • @git-amend
      @git-amend  Před 8 měsíci +3

      Haha, love this comment!

    • @keplaris2401
      @keplaris2401 Před 4 měsíci

      But should you use every pattern? I don’t think that is good?

    • @PsigenVision
      @PsigenVision Před 2 měsíci +1

      I just discovered git-amend in my process of just starting to learn the patterns...
      I got here somehow... and this was my first thought XD

    • @stickguy9109
      @stickguy9109 Před 2 měsíci

      @@PsigenVision Idk how he has them all memorized like that

  • @rofu8096
    @rofu8096 Před 8 měsíci +7

    As a junior dev i can truly say this content is way out of my league. But I will continue to watch until the day I can finally reach this level. Thank you for all your work!

    • @git-amend
      @git-amend  Před 8 měsíci +5

      I appreciate that! Keep learning something new every day!

  • @MarushiaDark316
    @MarushiaDark316 Před 8 měsíci +9

    This is some very high-level stuff. I'm an intermediate dev, meaning I know enough that I can respect the awesome power of what you're doing and see its utility value, but not quite enough that I can internalize or replicate all of it intuitively just yet. That said, this is giving me a direction to push my skills at least.
    I'm actually working on a series of videos about SOLID and Design Patterns geared more towards beginners and people who don't have a mind for coding and this has been really inspiring.

    • @git-amend
      @git-amend  Před 8 měsíci +4

      Great! Nothing better than sharing your knowledge -I will watch for your videos!

    • @MarushiaDark316
      @MarushiaDark316 Před 8 měsíci +1

      @@git-amend They'll be on my other channel Serket Studios

    • @ZiaGameDev
      @ZiaGameDev Před 8 měsíci +1

      ​@@MarushiaDark316sounds great! Dropped a sub on that and will keep an eye out for those 😁

  • @commander3192
    @commander3192 Před 22 dny

    Great video on dependency inversion. Loved all the rapid fire examples of how to accomplish it.

  • @alec_almartson
    @alec_almartson Před 8 měsíci +5

    Great video.
    I actually understood everything from the first minute... it's very well explained, and it goes step by step 💯👍🏻

    • @git-amend
      @git-amend  Před 8 měsíci +1

      Great to hear! Thank you!

  • @anasmostefaoui3027
    @anasmostefaoui3027 Před 8 měsíci +3

    This was also so helpful in my career, it clicks loose decoupling and as you mentioned the other solid princpale (helped with Liskov substitution too). I love the way you implies these concepts in game development. I loved game programming patterns by bob nystrom and was my reference for someone learning the patterns in a more expressive ways, but your channel is taking it to another level.
    Thanks again for all the time and effort.
    Of by the way, I scored 85% in my final project, and I promise you it would've been impossible without your content, so thank you so much

    • @git-amend
      @git-amend  Před 8 měsíci +1

      Wow, I’m glad to hear that about your project! Awesome! That’s fantastic news!

  • @marc8150
    @marc8150 Před 2 měsíci

    By the end of the video I forgot that I initially came here for dependency inversion. Great video :D

  • @512Squared
    @512Squared Před 7 měsíci

    The quality and density of your videos is outstanding.

    • @git-amend
      @git-amend  Před 7 měsíci

      Thanks, glad you like the vids!

  • @Cloud-Yo
    @Cloud-Yo Před 4 měsíci

    What a ride! from interfaces to injection to custom property drawers, builders and custom editor scripting...amazing video!

  • @axel.techart
    @axel.techart Před 8 měsíci

    Great video!
    I'm glad to hear that you like the foliage shaders, thank you a lot for sharing it with the community :)

    • @git-amend
      @git-amend  Před 8 měsíci +1

      Thanks Axel! I added a lot more foliage to my scene this week, and it's very performant. It looks great with a top down camera as well! Cheers!

  • @ThunderaRafa433
    @ThunderaRafa433 Před 6 měsíci

    The best ever channel I ve found for years... really good quality, special theese day, that begginners need to stay focus in Unity and not migrate to other ENgines... this whole series is a massive monster kill serie... I hope see many and more games and easy to do with this approach.

    • @git-amend
      @git-amend  Před 6 měsíci

      Thanks for the kind words!

  • @teh1archon
    @teh1archon Před 8 měsíci

    This is the best explanation on D of Solid I've come across.

  • @Caliums
    @Caliums Před 8 měsíci

    Great as always! Loved the idea with the icon for injected properties. I am using Zenject so I might actually extend it and add this, it's a really nice touch.

  • @laserbean00001
    @laserbean00001 Před 8 měsíci

    Thank you. I think this video clears up some stuff that i was confused about in the previous video.

  • @risingforce9648
    @risingforce9648 Před 8 měsíci +1

    Cool!! cool , I am very taking my best to understand special DI (cause I would like to implement more complex thing ) . thx and very xmas

  • @nathanbarraud4349
    @nathanbarraud4349 Před 7 měsíci

    Thank you so much !

  • @lukass1604
    @lukass1604 Před 8 měsíci

    Awesome video once again!

  • @manofapocalypse
    @manofapocalypse Před 8 měsíci

    How this Singleton works? 🤔

    • @git-amend
      @git-amend  Před 8 měsíci +2

      It's just a simple generic singleton. I showed it in the previous video briefly at the start of creating the generic singleton, so you can catch a glimpse of the code there:
      czcams.com/video/PJcBJ60C970/video.htmlsi=RW7k8aXLvv2RiPLH&t=211
      I will be creating a video on the Singleton pattern soon and we'll walk through the whole thing and a few other details.

  • @ekekw930
    @ekekw930 Před 8 měsíci

    Nice! Happy Holidays to you too!

  • @melipefello
    @melipefello Před 8 měsíci

    Hey, thanks for the video and taking the time to share and enlighten us wirh some knowledge. You, Storey and Guru are definitely the most structured teachers out there for experienced devs :)
    Since you touched the abilities subject, how would you architect a path of exile skill system with multiple triggers, phases and reactions? That's the most challenging system I've built but I'd love to learn from your take on it!
    Cheers :)

    • @git-amend
      @git-amend  Před 8 měsíci +1

      Thanks for your comment! This kind of Ability system you describe definitely sounds like a real challenge. I'll have to think about what my approach would be to such a system! It would be a good thought exercise at the least!

  • @damonfedorick
    @damonfedorick Před 8 měsíci +2

    can i get your top recommended books to read?

    • @git-amend
      @git-amend  Před 8 měsíci +4

      Sure. Here's some suggestions:
      Clean Code - Robert C. Martin
      Code Complete 2 - Steve McConnell
      The Pragmatic Programmer - Andrew Hunt and David Thomas
      Agile Software Development: Principles, Patterns, and Practices - Robert C. Martin
      Clean Architecture - Robert C. Martin
      Implementation Patterns - Kent Beck
      Algorithms - Robert Sedgewick
      Refactoring: Improving the Design of Existing Code - Martin Fowler
      Effective Java - Joshua Bloch
      C# in Depth - Jon Skeet
      Dependency Injection in .NET - Mark Seemann
      Enterprise Integration Patterns - Gregor Hohpe and Bobby Woolf
      Patterns of Enterprise Application Architecture - Martin Fowler
      Modern Software Engineering: Doing What Works to Build Better Software Faster - David Farley
      Accelerate: The Science of Lean Software and DevOps - Nicole Fosgren, Jez Humble, and Gene Kim
      Some of these books have examples in Java, but the principles are the same. (Ordered with more advanced books towards the end of the list)

    • @jacobs.7925
      @jacobs.7925 Před 8 měsíci +2

      Damn, outstanding video as always, everything by you is a must watch. Quick question, how long did it take you to get this good at coding? You are either incredibly gifted or very experienced (or both).
      I make a living from making games but my code quality is utterly terrible (spaghetti, scared to refactor, singletons, static methods everywhere 😂), trying to learn from great devs like you!

    • @git-amend
      @git-amend  Před 8 měsíci +3

      @@jacobs.7925 Thank you! Glad you like the vids! As to your question, I've been programming since I was a little kid, and it's been several decades since then. The most significant advancements in my skills have happened while working in enterprise software engineering. This is largely due to the invaluable experience of engaging in daily peer code review with other experienced engineers, and beyond that, the general attitude of trying to produce the most robust, efficient, and maintainable code possible. An environment like this fosters a culture of continuous improvement and collective responsibility for code quality, encouraging not just technical proficiency, but also a deep understanding of best practices and design principles.
      I still manage to learn something new everyday (usually at work), and that's part of what makes programming such a great job - doesn't matter what your skill level is, you can always learn new things and improve!

  • @unitydev457
    @unitydev457 Před 4 měsíci

    one part that I dont quite understand is around 5:45 - "all of your code will depend on this service locator, dependency injection will take this one stepfurther" doesnt that just mean your code depends on the DI framework? isnt it just trading one hard reference for another? edit: after reading more and watching more -> its not so much that you remove that dependency, its that you set it up to be automatically provided, right?

    • @git-amend
      @git-amend  Před 4 měsíci

      Correct - a concrete type that matches the interface will be provided from outside the class, so you can change which dependency will be provided without ever changing the class that depends on it.

  • @raymk
    @raymk Před 7 měsíci

    I need your enlightenment here.
    What's the difference between using the method you proposed in the video, and using ScriptableObject as the base class of AbilityData?
    Usually I make an abstract parent class (based on ScriptableObject), and multiple children classes, each of which implement different logic for the ability. As for how the AbilityData translates to character's movement, animation, etc., I make a new component (call it AbilityController) to handle it separately from the Hero script.
    In short, I can create as many custom abilities I want by making new scripts inherited from AbilityData. And if I want to add/remove abilities from the character, I'll just add/remove/edit the AbilityController that's attached to Hero's gameobject.
    -
    Maybe I just didn't catch the benefits of using this Dependency Inversion method? Or is it basically the same with ScriptableObject?

    • @git-amend
      @git-amend  Před 7 měsíci

      The Dependency Inversion principle is the principle of referencing abstractions instead of concrete types. It sounds like that is what you are doing with an abstract Scriptable Object to create an implementation of the Strategy pattern.
      For example:
      public abstract class AbilityBase : ScriptableObject {}
      public class CastAbility : AbilityBase { }
      public class AttackAbility : AbilityBase { }
      public class AbilityController : MonoBehaviour {
      public AbilityBase ability; // Dependency Inversion means you can use any Concrete Ability here
      }

    • @raymk
      @raymk Před 7 měsíci +1

      @@git-amend I see (maybe)! Thank you for replying.
      It would be awesome if one day you can contrast and compare different patterns to create a same game system (ability, inventory, etc.), so we can understand when to use them accordingly despite having the same purpose.
      I find it hard to learn new patterns because it seems like the methods I'm using is good enough for different cases if it's tweaked a bit.
      It might be a lot of work comparing different patterns, but I hope you consider my suggestion!
      Thanks

  • @lukass1604
    @lukass1604 Před 8 měsíci

    Do you have experience with Photon? Would love to see some videos on that

    • @git-amend
      @git-amend  Před 8 měsíci

      Only with on very small project. Maybe one day I’ll give it another shot.

  • @Andrew-pd2ci
    @Andrew-pd2ci Před 8 měsíci

    nicely done, can you make a video about Liskov principle?

  • @Sticks_Dev
    @Sticks_Dev Před 8 měsíci

    I'm sorry if you've answered this before or maybe even in the video and I missed it, but could dependent inversion also be used with abstract classes? Like if you're building a bow and arrow with different arrow types, you might have an abstract Arrow class that takes care of fundamentals like getting the reference to the rigid body but each implementation would need to fill the public abstract function OnImpact() for example.

    • @git-amend
      @git-amend  Před 8 měsíci +1

      Abstract classes do qualify as an abstraction in the context of Dependency Inversion. But, your example is describing inheritance where one class extends another, and maybe more specifically the Open/Closed Principle.
      In the context of the principle of Dependency Inversion, try to think of it more like you have an Arrow class (abstract or not) which depends on an abstract class TargetingStrategy. In this manner you can supply your Arrow class with concrete implementations of the dependency like Singleshot or Multishot. The abstract base class TargetingStrategy contains all the members common to the concrete strategies that extend it. In this manner, the Arrow class depends on any version of a TargetingStrategy and not one specific concrete type.

    • @Sticks_Dev
      @Sticks_Dev Před 8 měsíci

      @@git-amend That makes a lot of sense, thank you for clearing that up for me.

  • @manuelalonso415
    @manuelalonso415 Před 8 měsíci

    Hey! I love your videos! I have a question, how would you handle the dependency inversion in a case you are using a Monobehaviour AbilitySystem (or more than one for the same Hero)? These are the most frequent situation I met, where we want to use Editor tools, like listeners from UnityEvents or Scriptable Data attached to monobehaviours. Seems that Factory, ServiceLocator and DependencyInjector are not the suitable solution... The SerialzedField is the best option? (breaks the Interface asignations unless we use Odin or custom attributes as you mention)

    • @git-amend
      @git-amend  Před 8 měsíci +1

      Thanks for the comment! The Service Locator and the Dependency Injection framework we've built recently on the channel support providing references to MonoBehaviours. However, you are going to have a new challenge if you want to keep multiple instances of the same service on one game object so that you can configure them differently.
      The solution is usually to start separating the logic from the data - which is often the only difference between two instances of the same service. Expose the data/configuration and events via a MonoBehaviour which itself has a dependency on the actual service that will actually do the heavy lifting.
      Example:
      // Controller that you can attach to any GameObject and modify in the inspector
      public class AbilitySystemController : MonoBehaviour {
      [SerializeField] AbilitySystemConfig configuration;
      AbilitySystem abilitySystem;
      public UnityEvent OnEvent;
      void Start() {
      abilitySystem = ServiceLocator.For(this).Get().Initialize(configuration);
      abilitySystem.OnSomethingHappened += HandleEvent;
      }
      void HandleEvent() => OnEvent.Invoke();
      void OnDestroy() {
      if(abilitySystem != null){
      abilitySystem.OnSomethingHappened -= HandleEvent;
      }
      }
      }
      // Your configuration, strategies, unique logic for each service
      public class AbilitySystemConfig : ScriptableObject { }
      // Actual Service that does all the real work
      public class AbilitySystem {
      public event Action OnSomethingHappened = () => { };
      AbilitySystemConfig configuration;
      public AbilitySystem Initialize(AbilitySystemConfig config) {
      configuration = config;
      return this;
      }
      public void DoSomething() {
      OnSomethingHappened.Invoke();
      }
      }
      Here's a good read on this type of Architecture, though it's not in the context of Game Dev, it's the same principle:
      www.oreilly.com/library/view/software-architecture-patterns/9781491971437/ch01.html

    • @manuelalonso415
      @manuelalonso415 Před 8 měsíci

      Thanks for the response!@@git-amend

  • @damonfedorick
    @damonfedorick Před 8 měsíci

    Nice.

  • @Forture-fm1ve
    @Forture-fm1ve Před 8 měsíci

    Thank you, I have learned a lot from your videos.
    I am working on a gun system and using the Factory Pattern. Each type of gun has multiple shooting modes, and the damage dealt depends on the player's stats. However, every time I make a modification, I find myself having to delete and rewrite something. Can you provide an example?

    • @git-amend
      @git-amend  Před 8 měsíci +2

      Well, its hard to say. Usually when something is causing you to have to rewrite things often, it can mean that you need a little redesign. Refactoring will be the subject of a future video, but you might be able to solve your problem with the Strategy pattern - for example, each weapon might have a different Damage Strategy, or Shooting Mode Strategy. These can be passed into the Factory as data, and when each gun is created it depends on an abstraction (IDamageStrategy for example) instead of concrete logic. Try to find the pain point in your system and make it something you can swap out instead of have to change everything.

    • @Forture-fm1ve
      @Forture-fm1ve Před 8 měsíci

      @@git-amend Thank you for your answer. Perhaps I will have to delete the old code and rewrite a new one.

    • @Forture-fm1ve
      @Forture-fm1ve Před 8 měsíci

      g @git-amend I spent a few hours reworking my code, but there are still many parts I don't know how to change. For example, my gun deals damage based on the player's stats, and these stats change during runtime. I've tried every approach I could think of, but it still doesn't seem right. Could you provide an example of a gun to help me? Thank you for reading

    • @git-amend
      @git-amend  Před 8 měsíci

      @@Forture-fm1ve I don't think I can give you an example without fully understanding the requirements. If you send me a message on Twitter with a link to a gist (or some other way) containing your current code, and a detailed explanation of what you are trying to create, I will take a look when I have some free time.

  • @thev01d12
    @thev01d12 Před 8 měsíci

    Polymorphism is the core concept for solid principles and many design patterns.