In my learning of OOP, I came across a statement indicating that Beans should only be able to get/set properties of themselves. As such, many times I have a getProperty() and setProperty() for the necessary properties of a Bean.
But one of my properties is a struct, and I got to thinking "Well, the nature of this data should allow the user to perform not just 'set', but additional functions to add individual key/value pairs of data to that property. For example, a property called customHeaders (holds key/value pairs of header names and header values to be constructed when a response is generated) might have functions like:
addCustomHeader( name, value )
removeCustomHeader( name )
clearCustomHeaders()
But would functionality like this, because it is modifying property value, be something my ResponseBean would have in it, or is it something to better put into a ResponseService, that can be passed the ResponseBean object and then execute a ResponseService.addCustomHeader( ResponseBean, name, value ), etc.? This would keep ResponseBeans cleaner (with just gets and sets) and since the ResponseService would be a singleton, there would only be 1 instance of that object and its miscellaneous property modification functions rather than once for every transient ResponseBean instance.
Would love to hear your thoughts. Thanks!