I'm currently at the design phase of my program (hence no code).It will be written in WPF in C# using MVVM principles.I'm going to have a multifunctional Drag & Drop control, that will act similairly to a Facebook's Post on the Wall.To make this clear, imagine it could be a calendar event, an important note, a product update etc. That means they will differ in models that they will be based on.What do you think would be the most SOLID approach to building such a control?What I came up with:Have a single control object, that based on the type that it is created as, inherits different models. (though I'm not entirely sure how I will manage to do that yet.Have different controls for each type that all inherit from a base control class and extend the basic functionality.Any other solution, that could be even better?
MVVM Inheritance following SOLID principles
solid;wpf;mvvm
I try to follow the maxim favor composition over inheritance. In other words instead of baking in behavior at compile time, wire it up at runtime. This follows the Open/Closed Principle of SOLID, which states that code should be open to extension, but closed to modification. In other words, you should strive to design your code in a manner that you can extend its behavior (with abilities like drag-and-drop) without having to modify the existing source code (by modifying the base class to add drag-and-drop).IoC containers are useful for wiring objects up at runtime without having to change any code.