A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
As a result each SomeBean implements ISomeBean.
This construction will allow you to use the interface throughout your code without having the possibility to change the underlying bean.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
JavaBeans with all the getters & setters were created for a specific purpose, to allow tools like IDEs to dynamically discover the attributes and manipulate them with reflection.
Still, any time you write a get or set method is a good time to stop and think a little longer.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I write DTOs off as a necessary evil. They're not "good" objects; they're COBOL copy books or C structs.
Then I wonder why have private fields and getters and setters anyhow? If it's just a struct, make fields public, forbid any behavior and use them only where absolutely necessary on these boundaries.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
If we use them only as a message body going over a protocol the responsibility for maintaining valid state goes on the message sender or receiver or both, not on the message itself. We might as well use XML, CSV or delimited strings.
We had decades of very nice MVC designs with no DTOs. Communication over some non-object protocol makes them necessary
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Consider Paul's rocket mass heater. |