JavaBeans Naming
From Suhrid.net Wiki
Jump to navigationJump to searchJavaBeans are Java classes that have properties.
- Properties which are represented as private instance variables.
- Exposed through getters and setters.
Getters
- camel-case, prefixed with get: getPropertyName(). In case of boolean variable, prefix can also be "is".
- should be public, return type same as that of the property, void argument.
- e.g. public int getAge();
Setters:
- camel-case, prefixed with set: setPropertyName()
- should be public, return type void, and argument of the same type as the property
Events:
- Methods in the source to register events:
- camel-case, prefix with add or remove followed by Listener Class Name, with argument as the Listener object
e.g.
- public void addXListener(XListener xl);
- public void removeXListenerClassName(XListener xl);