So I'm writing a game and I've come across a conundrum where I believe Reflection might be a better solution. But knowing that Reflection is discouraged and my other solution doesn't look that pretty, I thought I'd ask here and see what's actually a better idea in this scenario.
Essentially I've got an abstract card class, and will have several implementations of it. I have a case where I'm given a card name and need to construct an object of it, just given the name.
I know I could use either:
a) Reflection and use forName and invoke. It'll be very short code, scale well, and easy enough to write. That said, it's Reflection, and I'm all for avoiding it when I don't particularly need it.
b) Use a Factory design pattern and then have a giant conditional check, calling the appropriate class based on the name I supply. It's not difficult to write but requires constant maintenance and will take a while to write, plus it won't scale well. That said, it's a non-Reflection solution.
So what is the ideal solution? Do I just use Reflection because it keeps my code nice and short?