
Design Patterns Part 1 – You Create Me!
Coding Blocks
00:00
Using Reflection in a Factory Pattern
In any factory situation, you really don't want to know the exact type of what's coming back because that allows you to loosely couple your code from what you're getting back. You just know that whatever interface that implements, it has a thing called make room, and you can call this, and then it'll work. But with this one, essentially what you have, this generally uses reflection quite a bit because it'll be based off either a config or something else. And depending on a config value or a type that you pass in, it's going to use reflection and say, okay, now I'm going to new up this type of factory.
Transcript
Play full episode