Q#2: If you don't like the underscore, leave it out. In my opinion it makes code more readable as it shows the scope of the variable. As an alternative you can use any other notation to distinguish between lokal and member variables (categories/mycategories or this.categories/categories).
Ralf ----- Original Message ----- From: "Keld Helbig Hansen" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, February 21, 2003 7:59 AM Subject: [castor-dev] Question 1 & 2 for Bruce's article: "contains" and underscores in names > Hi > These are the first questions related to the (excellent) article from DeveloperWorks >by Bruce Snyder: "Learn the basics of object-relational binding using Castor", august 2002: > http://www-106.ibm.com/developerworks/java/library/j-castor/ > > This article helped me a lot getting started withCastor-JDO, but it still leaves som >open questions. Here they come... > > Q#1: > In Listing 1. Product.java you find these statements: > > public void addCategory( Category category ) > { > if ( _categories.contains( category ) ) { > _categories.addElement( category ); category.addProduct( this ); > } > } > > (Remark: there's a missing NOT-operator in the "if"--ought to be corrected). > > Question is: why this check for existence of "category" in "_categories"? > It's obviously to avoid adding an object twice, but is it because Castor would do >this in some situations? > Or because a programmer could (by accident) use both addCategory and addProduct (in >the Category class)? > > Q#2: > What's the reason for using underscores as the first character in member variables? > > Thanx for any help. > > /Keld > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev > ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
