Multiple Interfaces
Subject: Multiple Interfaces
Newsgroups: gmane.comp.programming.domain-driven-design
Date: 2008-08-20 01:58:19 GMT
I recently had a vision about how to combat the abuse of the
pesky-but-needed getters and setters that are necessary for domain
objects that live in a real system and that have to be stored,
displayed, and sometimes created by external factories.
Anyway, since the getters and setters will end up being there anyway,
alongside your actual business logic methods, would it be better to
have the domain object implement multiple interfaces, one for each
layer of the system that has to see assorted getters and setters?
Here is what I'm talking about:
// for use with other domain objects; exposes meaningful business
logic methods only
public interface Customer
{
// our lone business logic method
void describe(CustomerDescription description);
}
// to be used when displaying a customer in UI and capturing a new one
from the user; TO stands for Transfer Object
public interface CustomerTO
{
String getFullName();
String getAddress();
void setFullName(String name);
void setAddress(String addr);
}
(Continue reading)
RSS Feed