vendredi 23 avril 2021

How to use polymorphism to create GUI classes from Model classes

I have the following situation.

  • model classes A, B, C implements general interface Model M
  • gui classes G_A, G_B, G_C implements general interface GUI G

The models are generated from an XML structure. The GUI classes should be generated from the models. How to do it in an elegant way?

I could check the type of the model (instanceof/switch) and create the GUIs, but in this way I don't take advantage of polymorphism and when a new GUI is introduced I have to complete the check/switch. Do you have a better suggestion?

Aucun commentaire:

Enregistrer un commentaire