Hi guys, Can somebody refresh me on the rules for boolean values in JavaBeans? Do they always use isMyBooleanValue notation and then have a get method starting with is and a set starting with setIs? I like to use booleans to setup static pieces of my SQL statements to either be on or off. Is this a safe pratice? Is it good OO to use lots of gets and sets for SQL statement pieces?
rules for booleans: variable name: active getter: isActive setter: setActive -OR- (This also works, at least in NetBeans) variable name: isActive getter: getIsActive setter: setIsActive (I personally (and purposefully) flout the official naming conventions and use the latter form, as it makes my variable names more meaningful and obvious.) As far as answering your SQL question, I don't know...I don't use static SQL statements--mine are built dynamically.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Howdy, I just wanted to clarify that according to the JavaBeans specification, both ways are fine: property name: active getter: isActive or getActive setter: setActive So the only difference is in the getter, and EITHER one is correct in the specification. So any true JavaBeans-compliant tool will work with either as part of a property. Remember, though, that it makes NO difference what you actually name the variable. You might not even *have* a single variable for a property. A property can be a "virtual" instance variable -- something that exists ONLY because there is a getter/setter for it And personally, I strongly prefer to use the naming convention, because if you anyone ends up using your class as a reusable component, and they want to use a high-level tool, it will make all the difference in the world that you followed it. cheers, Kathy
Joined: Aug 20, 2001
Whew-- Good to know that I'm not going too far from standard, if at all. I do have conventions--they were just in opposition to the "official" conventions that I came across (which stated that boolean getters should always start with isXXX, but since my variables were named isXXX, isIsXXX didn't make much sense. And since my components work in my beanbox, I assume I'm doing something right