mercredi 22 juillet 2020

What is the correct object-oriented design to handle the following UI case?

I have 2 views. Each view applies to a different user type: UserType1View and UserType2View. The views contain many subcontrols that have their own classes. ProfileControl, Stats1Control, Stats2Control, etc. These controls in turn are composed of various UI classes. This is a typical UI where you have several levels of aggregation. For sake of simplicity, lets say the 2 views are 99.9% identical, except 1 element buried down deep in the views. This element is a link and the destination of the link varies depending on the top level control: UserType1View or UserType2View. Essentially all elements / controls higher up in the aggregation are user agnostic, but this one element low down, isn't. What is the proper way to handle this case? Is it necessary to make every element / control in the aggregation path user gnostic so that this one element is also user gnostic? I run into this situation a lot and have never been satisfied with my own solutions. If there is a pattern that applies to this design case or a commonly acceptable solution, I'd like to know. Thank you.

Aucun commentaire:

Enregistrer un commentaire