Domain Driven Design - where does data parsing belong -
in application i'm developing, domain revolves around, say, electrical appliances. there several specialized versions of entity. appliances can submitted application, , happens web services using data transfer objects.
while working great, looking @ importing appliances several text-based file formats well. consider workflow:
- directory watcher service sees new appliance file has been added
- the service uses application service application submit appliances described file
now, application service have method following name , signature: applianceservice.register(string filecontents)
. i'm thinking directory watcher service use service method , pass entire contents of file. application service coordinate parsing. parsing contents of file , transforming complete appliances entities involves several steps. now, question is:
question: correct, or should parsing logic live within directory watcher service? each type of file format kind of part of domain, again, it's not. after files parsed entities either format, entity never know once represented using format. if parsing logic should live within watcher service, pass new appliances registration service data transfer objects.
i guess i'm concerned how appliance should represented before enters application (using application layer point of entry). when submitting appliances web services, pass sequence of appliance data transfer objects. different taking potentially oddly formatted file , parsing data transfer object, since mapping web service request data transfer object pretty straight forward, , not complex.
any thoughts on welcome.
according srp (single responsibility principle), should keep consideration. directory watcher service
should best - watch new files in directory , pass them service, ie appliance service
converts them data transfer objects. can use web services
submit data transfer objects application.
i make interface appliance service
, @ least 1 method called convert()
. appliance parsing service
class can implement interface. let's later have different source (sql) appliances. can write class appliance sql service
implements appliance service
.
Comments
Post a Comment