I was wondering best practices for views of inherited classes in PureMVC in this situation:
- Multiple classes inherit a BaseClass (lets say InheritedClass1 and InheritedClass2)
- Each InheritedClass has a respective view (derived from a base view class, but each unique)
- With a given dataset (lets say ArrayCollection of InheritedClass1/2 Objects), the respective views need to be dynamically loaded.
- The dataset is relatively large, so a TileList would be nice (since it only instantiates objects which are currently displayed)
I can think of a couple solutions, but I find them to be too "hackish" to be the best solution:
In View: Repeater over a BaseClassView which attributes a view to a State (set to the "InheritedClass1" state to add a InheritedClass1 object) Pros: No unneeded memory increase (States' objects are instantiated when needed) Cons: View is dependent on the data types, so adds coupling
In Mediator: Loop over the ArrayCollection and addChild() the views based on data type Pros: Works. Cons: Mediator is adding things to the View, which defeats the point of the separation of Mediator and View. Slower than a Repeater.
Any comments or other suggestions would be appreciated. Thanks!