mardi 11 août 2015

Design dilemma. What's the best design?

I have a design dilemma wherein:

  1. I have a UI action on my web page to allow the user to select a type from a list of types.

  2. Each type is defined by a POJO. I need to wrap this POJO (for the type which the user has selected) in a parent class and use it to perform an action.

  3. Each type can lead to a different action.

How do I design my parent class to support any type that the user selects? I want to avoid instanceof check while using the selected POJO later in my application.

Aucun commentaire:

Enregistrer un commentaire