Organizing Business and Presentation entities
- by simoneL
Background
I am developing a WPF project.
This is the basic structure:
User Interface (WPF Project);
Interfaces (class library, contains all the interfaces and the entities used by the application;
Modules (every module contains the logic of a specific argument, e.g. File Management, and can eventually contains Wpf User Controls).
In the WPF Controls, to facilitate the binding operations I have created a BaseViewModel class which contains a Raise method that automates the binding mechanism (for further details, I used a technique similar to that one described in this article).
The problem
Understand which is the best way to separate Presentation form from the Business form in the entities classes.
The case
In the Interfaces project I have, for instance, the class User
public class User
{
public virtual string Name { get; set; }
// Other properties
}
In one of the modules I need to use the User class and to bind its properties to the User Interface controls. To do so I have to use a custom implementation of the get and set keywords.
At first point, I thought to create a class in the Module called, for instance, ClientUser and override the properties that I need:
public class ClientUser : User
{
private string name;
public override string Name { get { return name; } set { Raise(out name, value); } }
// Other properties
}
The problem is the Raise method, which is declared in the BaseViewModel class, but due to C# single inheritance constraint, I can't inherit from both classes.
Which is the right way to implement this architecture?