Hi,
In the context of DDD setters on a domain model are a code smell. They should be avoided for the simple reason that they are not really part of the domain. There are no nouns in it that a Domain Expert may understand and changes to the data should go through specific methods instead.
Example:
customer.StreetName = ...
customer.City = ...
While the right way to do that would be to have a customer.ChangeAddress
method that could then publish an event etc etc.. At least from my understanding this is all sound theory and I can totally understand why setters in a domain model are not really desireable.
BUT: Without setters on your domain model, those methods get pretty hard to test.
How do I get a Customer instance to run my tests against if I can't construct one without having either a big-ass constructor that takes in ALL arguments, or do some reflection magic? I use NHibernate in the backend so NHibernate already does some reflection magic to populate these fields in the first place.
But it feels really bad to have a ctor with 10 arguments.. (And the same would be true for a factory method).
Any advice on this?
greetings Daniel