Violating Liskov Principle and Open Closure Using Template Selectors

I have WPF MVVM and ASP MVC applications that show information about students and teachers. The WPF app retrieves and stores student and teacher information from the web service and displays them in a list. Both students and teachers have a first name, last name and age. Each student also has a GPA (grade point average). Each teacher also has a photograph. The same list of students and faculty should appear in an ASP MVC application.

So, in my implementation, I have AbstractPersonDto, StudentDto and TeacherDto. I have a service:

interface IService
{
   IList<AbstractPersonDto> GetAllPersons();
   void SaveAllPersons(IList<AbstractPersonDto> persons);
}

      

I am also looking at models: AbstractPersonViewModel, StudentViewModel, TeacherViewModel in WPF and 3 more in ASP app.

The first question is: does the mapping from IList<AbstractPersonDto>

to violate the IList<AbstractPersonViewModel>

principles of Open-Closed and Liskov?

In my views in WPF and ASP MVC, I use DataTemplate and DisplayFor to select the appropriate template and partial view respectively.

So the second question is, does using these templates also violate the Open-Closed and Liskov principles or not?

UPDATE 1: Based on the comments, I think I need to clarify my question: If I use Automapper (ie) It will do something like "is" or a type of comparison behind the scenes. Or not? Also My MainViewModel contains links to the list, and my view through the DataTemplate iterates over that list outside of scripts and picks the appropriate template (sort of like an "is" statement). Does this mean that it would violate these principles? When I change something in Dto, I must also change my viewmodels (cascade effect).

+3


source to share





All Articles