So here is the situation, Say I have a class called factory, Factory is used for building cardViews to display to the user. In a Certain number of cases(currently small), The I want the card not to be dismissible(aka have an x at the top) or have any buttons on it that in other cases have functionality. Now say we have some class WholeDataProvider, and data provider has an object in it called currentEnvironment, with a field called cardEditable. Now the card factory currently does not know about WholeDataProvider, currentEnvironment..etc. Now this object is accessible in this case its just not currently imported. The factory method takes in a data model lets call it cardDataModel which tells the factory information on what card to layout and return. Now my Idea was to add a field to this model thats something along the lines of boolean drawInteractivity. Now the place where the cardDataModel is created already has the class WholeDataProvider imported so I chose to add the field to the card and not try and add dependencies in the creator class.
Now although this works, I am being told to add the call to WholeDataModel the factory class.
my question more or less is can anyone give me some rules or guidance or information...etc regarding the usage of data models in factory methods or an explanation as to why moving the call would be a better idea. to me it would seem that the data model should provide everything the factory needs to know.
Thanks for any comments or info.
Aucun commentaire:
Enregistrer un commentaire