views:

47

answers:

1

I have a class that need to be serialized (for both persistentcy and client-server communication)

for simplicity's sake let's call the classes Business a BusinessData and I prefix for their Interfaces.

All the getter and setter are delegated from Business class to BusinessData class.

I thought about implementing IBusinessData interface that will contain all the getter and setters and IBusiness interface that will extend it.

I can either make Business extend BuisnessData so I will not need to implement all getter and setter delegates, or make some abstract class ForwardingBusinessData that will only delegate getter and setters.

Any of the above option I lose my hierarchy freedom, do any of you have any creative solutions for this problem...

I also reviewed DAO pattern: http://java.sun.com/blueprints/patterns/DAO.html

A: 

I'm not sure if I understand the actual problem, but isn't this what you're looking for?

public interface IBusiness {
    public BusinessData find(Long id);
    public void create(BusinessData data);
    public void save(BusinessData data);
    public void delete(BusinessData data);
}

It makes by the way not much sense to create interfaces for model objects.

BalusC
I am not sure I understand the find function, do you mean that I'll supply the Data class as an accessor class that will supply all getter and setter?
ekeren
Yes, the data class can just be a javabean-like model class.
BalusC