jeudi 17 janvier 2019

How to design to avoid casting

I'm designing a software for displaying ModelView objects based on a DataModel.

The DataModel is displayed by a ModelView object which can itself contain a bunch of ViewObjects. It is like a container of ViewObjects to constitute to a ModelView and finally display the DataModel.

These ViewObjects can be dependent of each other inside the ModelView so for instance a position of one ViewObject may depend on another.

Then also the layout of the final screen is decided based on all of the ModelViews.

These ViewObject is inherited from a common BaseView class, but the client can simply add new ViewObject types to the hierarchy by inheriting from BaseView class. These derived classes may have specific functions to them which may need to be called in order to connect them together inside a ModelView.

Could you someone give me an idea how to do this without dynamic casting?

Aucun commentaire:

Enregistrer un commentaire