Many, many beans I write have no logic associated with their access methods, never will, and could do with this being made architecturally clear. In addition I would like to avoid the unnecessary verbiage of writing out dozens of identical access methods (yes, I know Eclipse makes this easier, but they still need to be read).
I propose that the Spring introspector be extended to allow properties to be resolved onto publically visible fields of the same name where they exist.
Why write this
public class Bean {
private String property;
public void setProperty(String property) {
this.property = property;
}
public String getProperty() {
return property;
}
}
When you really mean this?
public class Bean {
public String property;
}
The latter expresses intent far more clearly in many instances.
IMO this should have been in the bean spec from the start, and shows the continuing unhealthy impact of "OO" "thought" knocking on from the 90s. People have become so carried away with the architectural possibilities offered by overriding and interception of requests that it would seem they often ignore the possibility that in many instances this kind of affordance is unnecessary and extraneous.
This would require only a small change to Spring code and would offer a considerable convenience to users.


Reply With Quote