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

Поделиться
HTML-код
  • Опубликовано: 18 дек 2024

Комментарии • 79

  • @git-amend
    @git-amend  Год назад +10

    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 11 месяцев назад +29

    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  11 месяцев назад +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 11 месяцев назад +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!!

  • @rofu8096
    @rofu8096 11 месяцев назад +9

    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  11 месяцев назад +5

      I appreciate that! Keep learning something new every day!

  • @stickguy9109
    @stickguy9109 Год назад +28

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

    • @git-amend
      @git-amend  Год назад +5

      Haha, love this comment!

    • @Keplaris
      @Keplaris 8 месяцев назад

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

    • @PsigenVision
      @PsigenVision 6 месяцев назад +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 6 месяцев назад

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

  • @GTZ-98
    @GTZ-98 6 месяцев назад +2

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

    • @git-amend
      @git-amend  6 месяцев назад +1

      Thanks! 😃

  • @MarushiaDark316
    @MarushiaDark316 Год назад +12

    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  Год назад +5

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

    • @MarushiaDark316
      @MarushiaDark316 Год назад +1

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

    • @ZiaGameDev
      @ZiaGameDev 11 месяцев назад +1

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

  • @commander3192
    @commander3192 4 месяца назад +1

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

  • @TurderaTommy433
    @TurderaTommy433 10 месяцев назад +2

    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  10 месяцев назад +1

      Thanks for the kind words!

  • @Cloud-Yo
    @Cloud-Yo 8 месяцев назад +1

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

    • @git-amend
      @git-amend  8 месяцев назад +1

      Thank you very much!

  • @512Squared
    @512Squared 11 месяцев назад +1

    The quality and density of your videos is outstanding.

    • @git-amend
      @git-amend  11 месяцев назад +1

      Thanks, glad you like the vids!

  • @alec_almartson
    @alec_almartson Год назад +7

    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  Год назад +1

      Great to hear! Thank you!

  • @manofapocalypse
    @manofapocalypse 11 месяцев назад +1

    How this Singleton works? 🤔

    • @git-amend
      @git-amend  11 месяцев назад +3

      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:
      ruclips.net/video/PJcBJ60C970/видео.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.

  • @axel.techart
    @axel.techart 11 месяцев назад

    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  11 месяцев назад +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!

  • @Caliums
    @Caliums 11 месяцев назад +1

    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.

  • @teh1archon
    @teh1archon Год назад +1

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

  • @laserbean00001
    @laserbean00001 Год назад

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

  • @AstralNostalgia
    @AstralNostalgia Год назад +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

  • @unitydev457
    @unitydev457 7 месяцев назад

    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  7 месяцев назад

      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.

  • @ekekw930
    @ekekw930 Год назад

    Nice! Happy Holidays to you too!

  • @lukass1604
    @lukass1604 Год назад

    Awesome video once again!

  • @melipefello
    @melipefello 11 месяцев назад

    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  11 месяцев назад +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!

  • @Sticks_Dev
    @Sticks_Dev 11 месяцев назад

    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  11 месяцев назад +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 11 месяцев назад

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

  • @raymk
    @raymk 11 месяцев назад

    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  11 месяцев назад

      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 11 месяцев назад +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

  • @nathanbarraud4349
    @nathanbarraud4349 11 месяцев назад

    Thank you so much !

    • @git-amend
      @git-amend  11 месяцев назад

      You're welcome!

  • @Andrew-pd2ci
    @Andrew-pd2ci Год назад +1

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

  • @Forture-fm1ve
    @Forture-fm1ve Год назад

    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  Год назад +3

      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 Год назад

      @@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 11 месяцев назад

      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  11 месяцев назад

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

  • @manuelalonso415
    @manuelalonso415 11 месяцев назад

    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  11 месяцев назад +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 11 месяцев назад

      Thanks for the response!@@git-amend

  • @damonfedorick
    @damonfedorick Год назад +3

    can i get your top recommended books to read?

    • @git-amend
      @git-amend  Год назад +5

      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 Год назад +3

      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  Год назад +4

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

  • @lukass1604
    @lukass1604 Год назад

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

    • @git-amend
      @git-amend  Год назад +1

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

  • @damonfedorick
    @damonfedorick Год назад

    Nice.

  • @thev01d12
    @thev01d12 Год назад

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