So, I have to build a new Java application and I have a scenario where I'm inclined to use a Map of Objects with casts all around. I just don't like this idea though, but can't figure out a better solution.
Here's the scenario: I have some user input along with a tag that defines the action to be taken. First, based on the tag, the user input will be enriched with one or more objects, and then it will be passed along to a validator machine to be processed. These validators are somewhat generic, so they can be of use to one or more tags. That's where the Map comes in, it will be the validators input, because they know which key of the map to use.
I have been looking at the Chain of Command design pattern, but it uses a single request, and in my case the request can vary depending on the tag. Also, it's main purpose is already achieved with my validator machine.
Is there a better solution for this?
Aucun commentaire:
Enregistrer un commentaire