This a question which has baffled me for some time. When I interact with an object in Presentation, how do I find out to which Domain/Business object this relates?
I have Shape classes in my Domain/Business, I draw these Shapes using WPF on the screen (Presentation). So for example I have a class called LineShape in my Domain which I then draw in WPF using System.Windows.Shapes.Line.
Now here is my question, how do I keep the correspondence between the objects in Domain Layer and the Business Layer. Let's say the user clicks on a specific System.Windows.Shapes.Line in WPF, the UI fires an event and gives me the selected System.Windows.Shapes.Line, how do I now recognize which LineShape in my Domain the selected System.Windows.Shapes.Line represents?
I have thought about a few methods, but they do not seem elegant, specially for larger and more complex object models.
Use a dictionary that keeps the correspondence between the Presentation and Domain objects. In this method, when the user selects a
System.Windows.Shapes.Linein UI, I can look up the correspondingLineShapein domain in dictionary.Use an Id for objects both in Presentations and Domain. This sounds a bit strange to me, because as far as I am aware, we are not supposed to use Id for every object in DDD, just for entities.
Are there any best practices to follow here?