final CreditCardDetails paymentDetails = aVisa().billedTo(anAddress().withFirstName("John").withLastName("Leclair").withNumber("9999 9999 9999").withExpiryDate("12/12").build();
* The domain model does have a number of getters and setters. They
make it easy to hang more and more dependencies onto their classes.
Are there options to reduce these?
* I agree with David's point about moving more Controller-managed
communication to the domain objects themselves.
* Uncle Bob has recently been talking about Jacobson's use case
controllers, calling them Interactors. If' I'm not mistaken, these
Interactors correspond to DDD's notion of an application layer. Of
course this application layer should at most be a simple coordinator
of domain objects and know nothing about specific domain logic itself.
This layer lets you use any kind of front end (a competing web
product, web services, command line, thick client, etc.).
* I believe Uncle Bob suggests Interactors should communicate in terms
of data structures and exchange domain objects. Does this relate in
any way to Nat's recent comments about using meta-mapping at the
boundary level?
So I would ask
* How can the getters and setters be reduced or eliminated (an oft
repeated question)?
* Is there a need for some type of coordination (application,
interactor, etc.) layer?
* Should Spring MVC know anything about real domain objects?
* Would it be useful to use something like MVP with Spring MVC at the View?
I'm not sure whether there still might be some domain logic in the controllers that could be moved into the domain. For example, the PurchasesController (covered by the PurchasesControllerTest) calls a CheckoutAssistant to generate an Order from a Cart and then calls the PaymentCollector to collect payment on the order. Perhaps instead of using the controller to manage the communication between these objects, the objects could talk to each other and then callback the controller?
In this case, I believe that these are supposed to be valid credit card details, so you might name that variable "validCreditCardDetails" to make it clear. You might also pull this out into a private method (because the names, expiry dates, numbers etc. are kind of irrelevant to the test), or, even better, create static methods on the builder: validCreditCardDetails() and invalidCreditCardDetails() so that other tests can use them, if necessary.
> * I believe Uncle Bob suggests Interactors should communicate in terms
> of data structures and /_not_/ exchange domain objects. Does this relate in
> any way to Nat's recent comments about using meta-mapping at the
> boundary level?
Accolades to Vincent et al for putting this together.
* The domain model does have a number of getters and setters. They
make it easy to hang more and more dependencies onto their classes.
Are there options to reduce these?
* Uncle Bob has recently been talking about Jacobson's use case
controllers, calling them Interactors. If' I'm not mistaken, these
Interactors correspond to DDD's notion of an application layer. Of
course this application layer should at most be a simple coordinator
of domain objects and know nothing about specific domain logic itself.
This layer lets you use any kind of front end (a competing web
product, web services, command line, thick client, etc.).
* Should Spring MVC know anything about real domain objects?
I noticed the domain model has JPA entities, as well. A thing with
which I've been grappling is the pragmatism of applying JPA
annotations v. returning to the days of yesteryear by moving metadata
to external files or alternate mechanisms. JPA annotations are quite
verbose.
Now what happens if you change the storage mechanism with
annotation support? Do you rip out the old and replace the new
annotations?
Do the new and old annotations live side by side? This
is definitely not a criticism of the petstore: It's my own conflict
with the trend of Java annotation proliferation.
In Spring Roo they used aspects to solve this. So your class doesn´t
have the JPA annotations, but they used aspects to construct an
annotated class. In fact, Spring Roo prefers to use aspects do
construct many things. One aspect to toString(), one aspect to JPA
annotations etc. It is in this way because Spring Roo try to be a live
framework. So when you create a new field in your class, the framework
automatically change de JPA aspect, the toString() aspect, the view
etc.
I am not saying that it is the right approach. Just showing what others did.
--
Abraços,
Josué
http://twitter.com/josuesantos
Make your domain model object, Foo, immutable. Give it a low visibility constructor that takes a FooEssence. In Java, package visibility does it. In C++, make it a friend.
The FooEssence is mutable and has a factory method that validates the state and then constructs a Foo, passing itself (memento like) to represent the required state.
Might help.
Regards,
Lance