I'd like to use DTO's in my view models in lieu of my domain objects, however I'm having a hard time justifying the maintenance overhead of having to maintain two sets of properties for each domain object.
I was wondering if anyone has implemented or knows of a pattern where the properties of a domain object are separated from the object's actions without having to maintain two sets of properties.
One thought I had would be to have my domain object be only properties and attaching the actions as a subclass:
public class Person{
private String firstName;
private String lastName;
public String getFirstName(){
return this.firstName;
}
public String setFirstName(string firstName){
this.firstName = firstName;
}
...
}
public class PersonActions extends Person{
public void save(){
...
}
public Person get(){
}
}
This way still feels a bit kludgy as I'd have to pass around a PersonAction class if I wanted a full representation of the domain object.