Leave a comment if there is a particular programming pattern you'd like me to feature in a future episode - already planning Factory, Adapter and Mediator patterns. Hit the bell so you don't miss a thing!
Thank you, that's a very encouraging comment! The channel is definitely starting to grow a little faster lately because of this video, and more like it to come! Cheers!
@@git-amend You need to leverage your skills as a senior software engineer. Most tutorials/ videos target beginner levels. I've been working through all of yours, and they're all really informative. I also note your consistent release schedule. Just keep at it, once you hit a certain number you'll hopefully get a lot more subs because this channel deserves it. My main advice so far is have a look at your thumbnails, the text is really important and I often see "3D" or "Shoot Em Up" really clearly but can't see the rest - I personally don't think 3D or Shoot Em Up should have been the most prominent words but would have clicked if I had seen Parallax or Player Controller. In this thumbnail, "Game Programming Patterns" was very clear. The fluent builder less so, but I clicked based on programming patterns. Anyways, the video and audio quality are excellent and you are presenting really well. Its more of a case of getting that youtube algorithm to favor you. I've subscribed, hopefully the high quality content continues.
@@phoenixfire6559 Thanks for the comments and constructive criticism - it's always welcome. I think you are right about the text; I'm going to make some changes based on that suggestion - thank you!
THANK YOU! I didn't know I needed this knowledge and it fit right into my project, cleaning up a bit of code. It was so cool and easy to implement the builder with interfaces despite its complexity.
Thank you so much! I am trying to come up with a clean architecture for a study project, and our mentor is purely decorative, so I have no one to ask advice from, and your explanations really helped me understand how to use this pattern
There are a lot of tutorials about how to make games, but very few about how to write effective and clean code! Thank you for that. I'll definitely browse carefully the content of your channel! A gold mine!
Awesome video! Very well explained! I could definitely watch a playlist of 30 of these video tutorials about other patterns and good practices, it's so hard to identify when to use it, it always looks like magic to me...
I am so grateful that I found your channel! Really help me alot learning game programming the better way since I am learning by myself. This is an absolute gem
I've learnt so much from your channel, some goes over my head like this one, I'll need to watch it a few more times, and try putting it into a project before I get the hang of it I suspect
Depending on what you're doing, you could use what I call self builder, where you merge the builder and the class, so you could have a boolean ready, that you set once the class is set properly (can also have it read only and use an initialization method). That's useful if you need to modify the class a lot and you're not using inheritance, because the builder is somewhat redundant, because you need setters anyway. So instead of Var Eb=new enemybuilder() Eb.health=100 Eb.behavior=behavior.followplayer Var enemy=Eb.build() You have Var E=new enemy() E.health=100 E.behavior=behavior.followplayer E.init() (You can also use that with a fluent builder, where you return this, I did it that way for clarity as it's just an idea, this assumes properties which call setters with that syntax, which aren't available in all languages.) Otherwise you're juggling between 2 or 3 classes for basically no reason. Though where you'd want to use an external builder is if you need to enforce a "non null" (not necessarily null, but there's no desirable default) behavior, like for example, you want every enemy to have their hp or behavior set (could be more complex, like requireing either a sprite or a 3d model), an external builder can just return null, while with a self builder you have to check that it has been initialized. (I.e. with a builder you can't create a class with an invalid state, while with a self builder you can have one)
Great insights on the 'self builder' approach! It's a neat way to streamline object creation, especially when inheritance isn't a factor. Thanks for sharing this alternative!
Hey, even tho you are not as popular as you should be, this channel is a true knowledge treasure for my level so i hope you keep uploading regardless of your views and subs. these are super helpful and your explanations are easy to understand. thank you I would love if you can cover Strategy , Command , State patterns as well
Great video!, btw on 3:40 you wrote that we should consider initializing the Builder with a prefab but how is that done? what if your "Enemy" class is the prefab in question? Should I put the prefab as a parameter of the method Build()?
I would consider using a prefab if you have several components that are common to all of a particular type of thing, like an Enemy. So all Enemies might have the same mesh and colliders for example, and the prefab saves you having to create a new game object and set those for each one. You could pass a reference to that prefab as a parameter, and that way you only need to instantiate a version of that prefab with the additional settings you want set by the Builder. You could also have a factory that has references to many variations of Enemy prefabs that has a CreateEnemy() method - it might choose a prefab at random from a List, then use the Builder to do some additional configuration and return a ready to use Enemy.
I'd be very curious to see your take on a Composite Tree or even a behaviour tree. I built an implementation after reading a blog post by the developer of Project Zomboid, however I've had some trouble finding great use cases for it. Fantastic tutorials. I really hope your channel gains some traction
This is great information! The video would be better if the audio were higher quality, and the intro was better (or simply removed). I don't see very many smaller channels, but the first thing I notice in smaller channels is the lower quality audio. I liked the video. :)
Great tutorial. In the interest of completeness, could you suggest how you build from a prefab instead of creating and setting up a gameobject from code (as suggested in one of the on-screen tips in the video)?
Sure - you could either pass in the prefab as part of the constructor, or in the final Build() method. Here is an example: public class Builder { GameObject enemyObject; public Builder(GameObject prefab) { enemyObject = GameObject.Instantiate(prefab); } public Builder WithName(string name) { enemyObject.name = name; return this; } public Builder WithHealth(int healthValue) { var healthComponent = enemyObject.GetOrAdd(); healthComponent.SetHealth(healthValue); return this; } public GameObject Build() { return enemyObject; } }
There are 2 ways, and I have both but in the videos I use GitHub Copilot: github.com/features/copilot The other way is to use JetBrains AI Assistant: www.jetbrains.com/ai/ Both of these are paid plugins and cost $10/mo.
I'm used to Java at work and follow most design patterns. But I'm really struggling to use them with Unity 3D. I'm trying to build a minecraft like block system for my game and can't quite figure out a way to do this in a way that's very extendible. For now I'm just trying to figure out a way to create 100s of blocks in a way that I have a base block with all the properties for ex: isFlammable, isTransparent, textures (6 for each face) but I'd like a way to select uniformMaterialSetup, distinctMaterialSetup, topDownSidesMaterialSetup, etc. And then I just create 100s of prefabs? And store it somewhere, or in a way that I can apply a block type to any baseblock and it gets all the properties. I've explored scriptableobjects, OOP mechanics and patterns so far. But even in my head I can't build a proper architecure I'm happy with. Most of my struggles come from how the inspector interacts with classes and mesh vs code. Your videos have helped a lot after trying a lot of things for a few days, but I'd appreciate a guideline for how I should start thinking about this. Thanks a lot for these videos.
Thanks for the comment. I wonder if the Flyweight pattern might help you out with the blocks. By separating intrinsic data (e.g., textures, flammability) from extrinsic state (e.g., position, specific material setups), you can create a base block type and then efficiently instantiate and manage variations through shared data structures. The Flyweight can reference your base prefab. Then maybe a Factory / Builder combination to create all kinds of variations?
@@git-amend wow, I just started reading about this as I've not used it ever before and what it intends to do aligns very closely with what I want. I understand that in the end I will end up using most common patterns, but this is exactly what I was struggling with. What should be the outermost pattern if that makes any sense. Thank you so much. I will read more about this and comment back when I make progress.
@@bhaktijpatil Sounds good. I also have a video called Flyweight Factory that does something like this. The video is about projectiles, but you could do something similar for blocks.
Meh, the only think I really don't like about the "fluent builder strategy" that is done here, is that you end up coping the entire object that you want to build, having the builder return itself is the way to go, but without making a clone of the target object. So you don't have to duplicate everything. Quick example is to just add a new property like "isActive", so you have the get/set for the actual class, and now you have to duplicate everything in the builder, a new isActive property with also its getter and setters.
That's a good question, and a few people have asked if I will make a video about that - which I still need to decide. While I'm not happy about the actions of Unity management, I'm also not interested in watching it burn to the ground completely and potentially destroying the work of so many, especially those who make their living making tools for Unity. For the next few weeks at least, I'll focus on making videos that are more about software engineering principles, which are transferable to any modern programming language.
Leave a comment if there is a particular programming pattern you'd like me to feature in a future episode - already planning Factory, Adapter and Mediator patterns.
Hit the bell so you don't miss a thing!
In 11 minutes you taught me more than 7 whole classes about software engineering
Thank you, that's a very encouraging comment! The channel is definitely starting to grow a little faster lately because of this video, and more like it to come! Cheers!
@@git-amend You need to leverage your skills as a senior software engineer. Most tutorials/ videos target beginner levels. I've been working through all of yours, and they're all really informative. I also note your consistent release schedule. Just keep at it, once you hit a certain number you'll hopefully get a lot more subs because this channel deserves it.
My main advice so far is have a look at your thumbnails, the text is really important and I often see "3D" or "Shoot Em Up" really clearly but can't see the rest - I personally don't think 3D or Shoot Em Up should have been the most prominent words but would have clicked if I had seen Parallax or Player Controller. In this thumbnail, "Game Programming Patterns" was very clear. The fluent builder less so, but I clicked based on programming patterns.
Anyways, the video and audio quality are excellent and you are presenting really well. Its more of a case of getting that youtube algorithm to favor you. I've subscribed, hopefully the high quality content continues.
@@phoenixfire6559 Thanks for the comments and constructive criticism - it's always welcome. I think you are right about the text; I'm going to make some changes based on that suggestion - thank you!
THANK YOU! I didn't know I needed this knowledge and it fit right into my project, cleaning up a bit of code. It was so cool and easy to implement the builder with interfaces despite its complexity.
Awesome! I'm really glad it helped you out!
This guy is the hero we didn’t know we needed.
This one single video made my understanding of design pattern whole new level. Very high quality content.
Wow, thanks!
I finally managed to implement one of the patterns for something useful, I think :S
Excellent!
Thank you so much! I am trying to come up with a clean architecture for a study project, and our mentor is purely decorative, so I have no one to ask advice from, and your explanations really helped me understand how to use this pattern
Glad it was helpful!
There are a lot of tutorials about how to make games, but very few about how to write effective and clean code!
Thank you for that. I'll definitely browse carefully the content of your channel! A gold mine!
Thanks for the kind words!
Your channel is top tier for advance programming topics not limited to game development. Great work!
Glad you think so! Cheers!
Awesome video! Very well explained! I could definitely watch a playlist of 30 of these video tutorials about other patterns and good practices, it's so hard to identify when to use it, it always looks like magic to me...
Thanks! More to come!
I watched abt 10 vids within the last hour I feel 10x smarter already
Awesome!
nice idea for thumbnail! really caught my eye.
I am so grateful that I found your channel! Really help me alot learning game programming the better way since I am learning by myself. This is an absolute gem
Great to hear! Welcome aboard!
i am still pretty confused about most of your advanced topics, but i am getting there slowly, your content helps, thanks
Glad to hear that!
Your channel is pure gold 😊
Thank you! 😃
I've learnt so much from your channel, some goes over my head like this one, I'll need to watch it a few more times, and try putting it into a project before I get the hang of it I suspect
Absolutely. Try it out a few times, and it will click!
Great video, I would like to see more of this type of content.
Thanks, make sure to check out the rest of the playlist!
Depending on what you're doing, you could use what I call self builder, where you merge the builder and the class, so you could have a boolean ready, that you set once the class is set properly (can also have it read only and use an initialization method).
That's useful if you need to modify the class a lot and you're not using inheritance, because the builder is somewhat redundant, because you need setters anyway.
So instead of
Var Eb=new enemybuilder()
Eb.health=100
Eb.behavior=behavior.followplayer
Var enemy=Eb.build()
You have
Var E=new enemy()
E.health=100
E.behavior=behavior.followplayer
E.init()
(You can also use that with a fluent builder, where you return this, I did it that way for clarity as it's just an idea, this assumes properties which call setters with that syntax, which aren't available in all languages.)
Otherwise you're juggling between 2 or 3 classes for basically no reason.
Though where you'd want to use an external builder is if you need to enforce a "non null" (not necessarily null, but there's no desirable default) behavior, like for example, you want every enemy to have their hp or behavior set (could be more complex, like requireing either a sprite or a 3d model), an external builder can just return null, while with a self builder you have to check that it has been initialized. (I.e. with a builder you can't create a class with an invalid state, while with a self builder you can have one)
Great insights on the 'self builder' approach! It's a neat way to streamline object creation, especially when inheritance isn't a factor. Thanks for sharing this alternative!
The last tip with interfaces is awesome!!!
Right on!
Using the fluent builder as a child class of a scriptable object finally lets me create instances in tests without making public setters. Amazing!
That's a great usecase!
Congratulations on pleasing the algorithm and hitting that programming/manhwa recap cross section with your thumbnail
Thanks! I had a lot of fun with the thumbnail! Stay tuned for more!
Hey, even tho you are not as popular as you should be, this channel is a true knowledge treasure for my level so i hope you keep uploading regardless of your views and subs. these are super helpful and your explanations are easy to understand. thank you
I would love if you can cover Strategy , Command , State patterns as well
I appreciate the comment! Those are great suggestions!
I learned, i liked, i subscribed. I will put this knowledge to good use in my Godot project. Thank you very much.
Awesome, thank you! Nice thing about programming patterns is you can use the knowledge in almost all modern programming languages!
Just a comment for support. Good stuff 💪keep it up!
Appreciate it!
Whooa, Great thx. Now i finnaly understand what difference between the two. Not as big as i excepted.
Awesome!
Great video!, btw on 3:40 you wrote that we should consider initializing the Builder with a prefab but how is that done? what if your "Enemy" class is the prefab in question? Should I put the prefab as a parameter of the method Build()?
I would consider using a prefab if you have several components that are common to all of a particular type of thing, like an Enemy. So all Enemies might have the same mesh and colliders for example, and the prefab saves you having to create a new game object and set those for each one. You could pass a reference to that prefab as a parameter, and that way you only need to instantiate a version of that prefab with the additional settings you want set by the Builder. You could also have a factory that has references to many variations of Enemy prefabs that has a CreateEnemy() method - it might choose a prefab at random from a List, then use the Builder to do some additional configuration and return a ready to use Enemy.
I'd be very curious to see your take on a Composite Tree or even a behaviour tree. I built an implementation after reading a blog post by the developer of Project Zomboid, however I've had some trouble finding great use cases for it. Fantastic tutorials. I really hope your channel gains some traction
Great suggestion! I have a related topic already on my todo list, and I'll jot this down as well. Thanks!
This is great information!
The video would be better if the audio were higher quality, and the intro was better (or simply removed). I don't see very many smaller channels, but the first thing I notice in smaller channels is the lower quality audio.
I liked the video. :)
Glad you liked the info! Thanks for the feedback - all suggestions are welcome!
Great explanation!! Thank you!
You're very welcome!
nice and clear
Thank you!
Great tutorial. In the interest of completeness, could you suggest how you build from a prefab instead of creating and setting up a gameobject from code (as suggested in one of the on-screen tips in the video)?
Sure - you could either pass in the prefab as part of the constructor, or in the final Build() method. Here is an example:
public class Builder {
GameObject enemyObject;
public Builder(GameObject prefab) {
enemyObject = GameObject.Instantiate(prefab);
}
public Builder WithName(string name) {
enemyObject.name = name;
return this;
}
public Builder WithHealth(int healthValue) {
var healthComponent = enemyObject.GetOrAdd();
healthComponent.SetHealth(healthValue);
return this;
}
public GameObject Build() {
return enemyObject;
}
}
What's the purpose for Build() method in this context? Does it pass the enemy referece to other classes?
amazing tutorial...!
Haha are you binge watching all the videos? 😀
@@git-amend yeah, it is really helpful. The real-world example in video are great. I wish I can watch these video earlier. Thanks a lot.
How do you get to use the single line and multiline code prediction and completion in Rider?
There are 2 ways, and I have both but in the videos I use GitHub Copilot: github.com/features/copilot
The other way is to use JetBrains AI Assistant: www.jetbrains.com/ai/
Both of these are paid plugins and cost $10/mo.
I like this kinda videos. My code always suffers from excess spaghetti
Awesome! Using patterns can make a world of difference in your projects!
Pretty useful thank you :D
Awesome!
Subscribed!
Awesome, welcome to the channel! More great content is on the way!
I'm used to Java at work and follow most design patterns. But I'm really struggling to use them with Unity 3D.
I'm trying to build a minecraft like block system for my game and can't quite figure out a way to do this in a way that's very extendible.
For now I'm just trying to figure out a way to create 100s of blocks in a way that I have a base block with all the properties for ex: isFlammable, isTransparent, textures (6 for each face) but I'd like a way to select uniformMaterialSetup, distinctMaterialSetup, topDownSidesMaterialSetup, etc. And then I just create 100s of prefabs? And store it somewhere, or in a way that I can apply a block type to any baseblock and it gets all the properties.
I've explored scriptableobjects, OOP mechanics and patterns so far. But even in my head I can't build a proper architecure I'm happy with.
Most of my struggles come from how the inspector interacts with classes and mesh vs code.
Your videos have helped a lot after trying a lot of things for a few days, but I'd appreciate a guideline for how I should start thinking about this.
Thanks a lot for these videos.
Thanks for the comment. I wonder if the Flyweight pattern might help you out with the blocks. By separating intrinsic data (e.g., textures, flammability) from extrinsic state (e.g., position, specific material setups), you can create a base block type and then efficiently instantiate and manage variations through shared data structures. The Flyweight can reference your base prefab. Then maybe a Factory / Builder combination to create all kinds of variations?
@@git-amend wow, I just started reading about this as I've not used it ever before and what it intends to do aligns very closely with what I want. I understand that in the end I will end up using most common patterns, but this is exactly what I was struggling with. What should be the outermost pattern if that makes any sense. Thank you so much. I will read more about this and comment back when I make progress.
@@bhaktijpatil Sounds good. I also have a video called Flyweight Factory that does something like this. The video is about projectiles, but you could do something similar for blocks.
Meh, the only think I really don't like about the "fluent builder strategy" that is done here, is that you end up coping the entire object that you want to build, having the builder return itself is the way to go, but without making a clone of the target object. So you don't have to duplicate everything. Quick example is to just add a new property like "isActive", so you have the get/set for the actual class, and now you have to duplicate everything in the builder, a new isActive property with also its getter and setters.
Cool video, but some of the sound effects near the beginning were too loud.
Thanks for the feedback, I'll keep that in mind.
Can you make a video about adapter pattern
Yes, I've got that on my to-do list!
Why you still using unity? Just curious
That's a good question, and a few people have asked if I will make a video about that - which I still need to decide. While I'm not happy about the actions of Unity management, I'm also not interested in watching it burn to the ground completely and potentially destroying the work of so many, especially those who make their living making tools for Unity. For the next few weeks at least, I'll focus on making videos that are more about software engineering principles, which are transferable to any modern programming language.