Question: If I had a model object, call it Employee
, and I wanted to expose different views of the person object depending on the consumer of the object, like a : ManagerEmployeeView
, EmployeeEmployeeView
or OwnerEmployeeView
, what is this pattern called? Is it any good? What are the standard nomenclatures associated with such designs? I ask so that I don't reinvent the wheel.
Purpose: After modeling an object, I want to expose different "views" to consumers such that I only give them what they need and nothing more - for security sake and other purposes. The so called "views" are not to be mistaken with an MVC view, i.e. it does not render anything, it is only a model.
Thoughts: The models are rich model, not anemic, thus the views not only abstract properties but also provide different behaviors. I would like to know if there are similar approaches so that I can learn from them. Naming styles for such an approach/models is more than appreciated, even though it may be considered subjective, I feel as though proper naming is an important step to master the idea. ViewModels
come to mind as a solution, but call it cargo cult, ViewModels
are usually employed as a model for a view (UI) and not a "model for a model" (if that makes any sense) - correct me if I'm wrong.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire