Re: [NetBeans]changing menuitems
- From: thufir <hawat.thufir@xxxxxxxxx>
- Date: Sun, 27 Jul 2008 01:39:28 GMT
On Sat, 26 Jul 2008 13:06:04 -0700, Mark Space wrote:
- these 2 methods :
public static GenListView getInstance() {
return instance;
}
This is pretty ugly. Returning a refernce to a private field? Ouch,
this totally breaks encapsulation
Huh?
In the second approach to implementing singletons, the public member
is a static factory method:
// Singleton with static factory
public class Elvis {
private static final Elvis INSTANCE = new Elvis();
private Elvis() { ... }
public static Elvis getInstance() { return INSTANCE; }
public void leaveTheBuilding() { ... }
}
Effective Java
Second Edition
page 17
ITEM 3: ENFORCE THE SINGLETON PROPERTY WITH A PRIVATE CONSTRUCTOR OR AN
ENUM TYPE
provided instance is final, it should be capitalized, else looks pretty
standard to me. ?
-Thufir
.
- Follow-Ups:
- Re: [NetBeans]changing menuitems
- From: Mark Space
- Re: [NetBeans]changing menuitems
- References:
- [NetBeans]changing menuitems
- From: Daniel Moyne
- Re: [NetBeans]changing menuitems
- From: Mark Space
- [NetBeans]changing menuitems
- Prev by Date: Re: [NetBeans]changing menuitems
- Next by Date: Re: Text in if condition is not displayed in the browser
- Previous by thread: Re: [NetBeans]changing menuitems
- Next by thread: Re: [NetBeans]changing menuitems
- Index(es):
Relevant Pages
|