DTOs and interfaces
apache-flex, architecture, dto, java
Solution
I don't see why interfaces and DTO's would not work together.
Consider a factory/assembler that creates domain objects from DTO's. You could configure the factory with strategies so that it is able to create specific implementations of a domain object based on the type of DTO it is given. The DTO would ideally be typed to an interface here. (This works in the opposite direction as well).
I'm not saying that you should put every DTO behind an interface, but just as with domain objects, there will certainly be cases where it is beneficial to do so.
Problem
I recently ran across this pattern(?) in our code and wondering how it is useful, if at all. We have a Spring app and a Flex front-end using BlazeDS. It was decided that we use interfaces on our DTOs, like so: Java ``` public interface ISomeDTO { Integer setId(); void getId(Integer i); } public class SomeDTO implements ISomeDTO { .. } ``` Actionscript ``` public interface ISomeDTO { var id:Integer; } public class SomeDTO implements ISomeDTO { .. } ``` What does an interface on a DTO gain you? These are lightweight objects with absolutely zero logic. DTOs make sense, interfaces make sense, but not together.