I have a view showing a list of people. For the specified view, I createdPersonListViewModel
class PersonListViewModel {
public IEnumerable<Person> People {get;set;}
public int TotalPersonCount {get;set;}
public int PeoplePerPage {get;set;}
public string OrganizationName {get;set;}
}
My question is about class Person. Where should the class be defined Person? And what should I name?
This problem is an instance of the more general problem of matching types between restricted contexts or levels. I understand that I can use AutoMapper, etc. To perform some of these work, but AutoMapper only fixes the problem, but does not solve it.
Here are some options that I have reviewed along with the pros and cons:
Place the classes PersonListViewModeland Personin the same namespace, for example. Whatever.Organization.ViewModels.
Pro: Personthe class name shows what it is - the person and the context that this class is associated with the specified namespace. Con: In the presenter, where I create this instance Person, (most likely) they will encounter a class Personfrom the business domain space, so I will have to prefix one of them. Con: you will need to add a namespace to contain view models (not necessarily a problem, as you can and I already have a namespace for view models).
Person PersonListViewModel.
Pro: Person .
Pro: Person , .
Con: Person . Inb4: , ViewModels , , -viewmodel , . , 5% , - .
Postfix * ViewModel
Pro: .
Con: , Person - , , - , [sub] view - , , , PersonListViewModel, Person ( int of TotalPersonCount - , ).
, . №1 (), , .