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

  Рет қаралды 8,324

git-amend

git-amend

Күн бұрын

Пікірлер: 79
@git-amend
@git-amend 11 ай бұрын
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 ай бұрын
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 ай бұрын
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 ай бұрын
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 11 ай бұрын
So how many patterns do you want to use? git-amend: yes
@git-amend
@git-amend 11 ай бұрын
Haha, love this comment!
@Keplaris
@Keplaris 7 ай бұрын
But should you use every pattern? I don’t think that is good?
@PsigenVision
@PsigenVision 5 ай бұрын
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 5 ай бұрын
@@PsigenVision Idk how he has them all memorized like that
@rofu8096
@rofu8096 11 ай бұрын
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 ай бұрын
I appreciate that! Keep learning something new every day!
@GTZ-98
@GTZ-98 5 ай бұрын
By the end of the video I forgot that I initially came here for dependency inversion. Great video :D
@git-amend
@git-amend 5 ай бұрын
Thanks! 😃
@commander3192
@commander3192 3 ай бұрын
Great video on dependency inversion. Loved all the rapid fire examples of how to accomplish it.
@git-amend
@git-amend 3 ай бұрын
Appreciate it!
@MarushiaDark316
@MarushiaDark316 11 ай бұрын
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 11 ай бұрын
Great! Nothing better than sharing your knowledge -I will watch for your videos!
@MarushiaDark316
@MarushiaDark316 11 ай бұрын
@@git-amend They'll be on my other channel Serket Studios
@ZiaGameDev
@ZiaGameDev 11 ай бұрын
​@@MarushiaDark316sounds great! Dropped a sub on that and will keep an eye out for those 😁
@Cloud-Yo
@Cloud-Yo 7 ай бұрын
What a ride! from interfaces to injection to custom property drawers, builders and custom editor scripting...amazing video!
@git-amend
@git-amend 7 ай бұрын
Thank you very much!
@512Squared
@512Squared 11 ай бұрын
The quality and density of your videos is outstanding.
@git-amend
@git-amend 11 ай бұрын
Thanks, glad you like the vids!
@TurderaTommy433
@TurderaTommy433 9 ай бұрын
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 9 ай бұрын
Thanks for the kind words!
@alec_almartson
@alec_almartson 11 ай бұрын
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 11 ай бұрын
Great to hear! Thank you!
@manofapocalypse
@manofapocalypse 11 ай бұрын
How this Singleton works? 🤔
@git-amend
@git-amend 11 ай бұрын
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: kzbin.info/www/bejne/hnvGc31sZahsbZIsi=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.
@teh1archon
@teh1archon 11 ай бұрын
This is the best explanation on D of Solid I've come across.
@git-amend
@git-amend 11 ай бұрын
Wow, thanks!
@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 ай бұрын
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 ай бұрын
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.
@git-amend
@git-amend 11 ай бұрын
Right on!
@laserbean00001
@laserbean00001 11 ай бұрын
Thank you. I think this video clears up some stuff that i was confused about in the previous video.
@git-amend
@git-amend 11 ай бұрын
Glad to hear it!
@lukass1604
@lukass1604 11 ай бұрын
Awesome video once again!
@git-amend
@git-amend 11 ай бұрын
Thank you! Cheers!
@ekekw930
@ekekw930 11 ай бұрын
Nice! Happy Holidays to you too!
@git-amend
@git-amend 11 ай бұрын
Thank you! Cheers!
@AstralNostalgia
@AstralNostalgia 11 ай бұрын
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
@git-amend
@git-amend 11 ай бұрын
Right on!
@Andrew-pd2ci
@Andrew-pd2ci 11 ай бұрын
nicely done, can you make a video about Liskov principle?
@git-amend
@git-amend 11 ай бұрын
Absolutely!
@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 ай бұрын
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!
@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 ай бұрын
@@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!
@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.
@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 ай бұрын
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.
@lukass1604
@lukass1604 11 ай бұрын
Do you have experience with Photon? Would love to see some videos on that
@git-amend
@git-amend 11 ай бұрын
Only with on very small project. Maybe one day I’ll give it another shot.
@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 ай бұрын
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
@Forture-fm1ve
@Forture-fm1ve 11 ай бұрын
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 11 ай бұрын
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 11 ай бұрын
@@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.
@damonfedorick
@damonfedorick 11 ай бұрын
can i get your top recommended books to read?
@git-amend
@git-amend 11 ай бұрын
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 11 ай бұрын
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 11 ай бұрын
@@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!
@damonfedorick
@damonfedorick 11 ай бұрын
Nice.
@git-amend
@git-amend 11 ай бұрын
Thank you! Cheers!
@thev01d12
@thev01d12 11 ай бұрын
Polymorphism is the core concept for solid principles and many design patterns.
How to do MORE with the Observer Pattern
13:09
git-amend
Рет қаралды 12 М.
NVIDIA’s New AI: Stunning Voice Generator!
6:21
Two Minute Papers
Рет қаралды 109 М.
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 158 МЛН
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 189 МЛН
This Game Is Wild...
00:19
MrBeast
Рет қаралды 195 МЛН
Service Locator: Inversion of Control in Unity C#
19:04
git-amend
Рет қаралды 12 М.
Why is Python 150X slower than C?
10:45
Mehul - Codedamn
Рет қаралды 30 М.
Unity Behavior Graph in 150 Seconds | Quick Workflow Preview (First Look)
3:08
UniTask: How It Replaces Coroutines, Tasks and Awaitable
24:49
Code Like a Pro: Refactoring to Patterns!
25:52
git-amend
Рет қаралды 7 М.
How I Simplify Unity Development with the Façade Pattern
12:42
The Unity HACK that the PROS know
21:27
git-amend
Рет қаралды 17 М.
Better Singletons in Unity C#
14:08
git-amend
Рет қаралды 9 М.
Getting Started with UniRx
5:33
Infallible Code
Рет қаралды 36 М.
It's EASY to think your code will always be UGLY!
15:28
git-amend
Рет қаралды 8 М.