The Artima Developer Community
Sponsored Link

Legacy Design Forum
Designing Fields and Methods

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

"Uniform access" may help

Posted by Jeevaka on September 19, 2000 at 1:06 AM


Yes, Java's direct inclusion of static final values can cause hidden problems that are hard to detect. I started reading the forum notes when I sensed the problem while reading the article.

A solution, though it may be a bit idealistic, is to follow the "uniform access" priciple. I.e. not to have any public fields and access to all fields through "get" functions. In the coffie cup example, we would be replacing "if (cup.getSize() == CoffeeCup.TALL)" by something like "if (cup.isTall())". How does that sound?




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us