Domain Driven Design - data centric module inside larger DDD system
We're developing a DDD based system. For a particular module (the publisher) in that system, we will receive data from other objects and perform transformations on them, then write out data files.
The DDD design being developed has many custom collection classes for data...all of these objects simply contain rows of data, but they have distinct class and property names. Is there a good strategy or pattern for dealing with this situation? I.e. a way to apply the same logic to all of these objects.
Further details: For example, we may have a DataType123 class that contains a collection of Data123Row objects. Then a type Data456 class containing a collection of Data456Row objects. Let's say there are 15 differnt objects like these. Due to the DDD ideas they have domain-based names, but they are really all more or l开发者_StackOverflow社区ess tabular data i.e. rows and columns. We are trying to create a generic service that can treat them all the same, even though they are technically different classes.
At a guess, it looks like Service (DDD) and Adapter (GoF) patterns would be a good starting point.
As the data transformation isn't a domain centric activity, call them via Services (which in turn use the Adapters to transform the data)
It sounds to me like you need a DataType base class and a DataRow base class which your transformation algorithms work with.
Then use a Factory pattern for constructing your objects.
If you're using C# you could use reflection to access all of the properties in a generic way.
Or if your transformation algorithms need to access specific property names then your Factory(s) could handle the construction of DataType123, DataRow123 and TransformationAlgorithm123.
Your question is a little unclear. DDD is all about the repository pattern to persist your value objects. Are you looking for other patterns to deal with something in particular? It's not clear what you're trying to accomplish here.
精彩评论