Mike is a fantastic educator and I think if this talk was just in the back to basics track, and not the software design track, there would have been a lot less annoying nitpicky comments/“questions” from professionals with their egos hurt by being taught something they already know.
A great approach for mimicking somehow a virtual constructor in the abstract class and allowing for the run time object creation. I think using modern features of c++ like std::function, lamda, code injection (or the old feature, macro), we can make it more general. So that we can auto generate the required static members and methods. We also can generat various constructor intrefaces for the object.
I tried to extend your fancy registration style factory pattern. I wanted just two things: 1. Don’t force the concrete create method to obey a fixed constructor function signature (use variadic template). 2. Use std::function… I flamed out miserably, perhaps because I was running on 5 hours of sleep and 3 cups of coffee…
My gripe is not with running interspersed updates and renders (which you admit is a problem) but with keeping all game objects as `Rc`. Wouldn't keeping objects of the same concrete type in individual dense non-dynamic collections (whether all together like in your prototype or split into Components within Systems) rather than a single collection of heterogenous dynamic objects always win?
Is there any way in C++ to write this code using a generic like you might in C#? Like instead of Factory::Create(“ant”, 5, 5) could you do Factory::Create(5, 5) ?
template void MakeItComplicated(T* any) { any->compilcated = Factory::CreateComplicated(5,5); } Can also be done using concepts, if you want to be fancy. Or just .. Ant ant; ant.complicated = Factory::CreateCompilcated(5,5);
I honestly don't think this is a good example of a use case for the factory pattern. In games you're more likely to use(and you should probably use) an ecs. In what case it can be useful in in games is in combination with a state pattern. That's pretty much the only instance where we use factories in our real-time applications.
Thanks for having me CppCon! I hope folks enjoy this pattern! :)
Thanks for the great talks, Mike!
You're an asset to the back to basics track.
When I learnt about Factory Pattern the first thing came in my mind what Command and Conquer:) Awesome job Mate 👏
Mike is a fantastic educator and I think if this talk was just in the back to basics track, and not the software design track, there would have been a lot less annoying nitpicky comments/“questions” from professionals with their egos hurt by being taught something they already know.
A great approach for mimicking somehow a virtual constructor in the abstract class and allowing for the run time object creation. I think using modern features of c++ like std::function, lamda, code injection (or the old feature, macro), we can make it more general. So that we can auto generate the required static members and methods. We also can generat various constructor intrefaces for the object.
I tried to extend your fancy registration style factory pattern. I wanted just two things: 1. Don’t force the concrete create method to obey a fixed constructor function signature (use variadic template). 2. Use std::function…
I flamed out miserably, perhaps because I was running on 5 hours of sleep and 3 cups of coffee…
Really enjoyed the talk Mike.
You should do the State design pattern next as that is one I have trouble understanding😉
My gripe is not with running interspersed updates and renders (which you admit is a problem) but with keeping all game objects as `Rc`.
Wouldn't keeping objects of the same concrete type in individual dense non-dynamic collections (whether all together like in your prototype or split into Components within Systems) rather than a single collection of heterogenous dynamic objects always win?
Why was the singleton create method required? Wouldn't it be likely that one would create more than one instance of ant?
Is there any way in C++ to write this code using a generic like you might in C#? Like instead of Factory::Create(“ant”, 5, 5) could you do Factory::Create(5, 5) ?
template
void MakeItComplicated(T* any)
{
any->compilcated = Factory::CreateComplicated(5,5);
}
Can also be done using concepts, if you want to be fancy.
Or just ..
Ant ant;
ant.complicated = Factory::CreateCompilcated(5,5);
I try with lambda is working well, better make it whole class as templates with function type or something like that.
41:47
Inheritance bad REEEEE
I honestly don't think this is a good example of a use case for the factory pattern. In games you're more likely to use(and you should probably use) an ecs.
In what case it can be useful in in games is in combination with a state pattern. That's pretty much the only instance where we use factories in our real-time applications.