Bean Pattern

Should the bean pattern (ie. JavaBean) be considered its own pattern?

Briefly: An object has parameters (private fields) that are modified by public MutatorMethods? getSomething() (GetterMethod?) and setSomething(something) (SetterMethod?)

public class Bean {
	private Object something = null;
	public void setSomething(Object something) {
		this.something = something;
	public Object getSomething() {
		return this.something;

What are getSomething and setSomething but new names and code for "something" as an r-value and "something =" respectively? All we're doing here is overriding those basic implementations and renaming them. Admittedly this does give us finer-grained control over access as well - we don't have to expose both methods.


The SetterMethod? may include access restrictions to:

	public void setSomething(Object something) {
		if(!isValidSomething(something)) {
			throw new IllegalArgumentException(something + " is not foo enough.");

this.something = something; }

EditText of this page (last edited May 17, 2004) or FindPage with title or text search