Is there any reason why value objects cannot have set methods?
Alex Chaffee Alan's original question (in full) was:
The J2EE spec strongly recommends the use of Value Objects (simple, structure-like classes) for passing data back and forth between EJBs and EJB clients. These objects are characterized by get methods for accessing class variables and the use of wholesale constructors. Is there a technical reason why these objects cannot have set methods? Or is it purely to reinforce the notion that I am not directly interacting with an EJB object? Specifically, I would like to get a value object from an EJB method, update some of the data, and ship it back. Of course, value objects are necessarily serializable.In my opinion, he answered his own question: value objects may contain any methods you like, including setters. It's just Java. In fact, I usually provide setters for mine. If anyone knows of a reason not to, please submit feedback.