Re: Can use of singletons denote poor project design?
- From: "Phlip" <phlipcpp@xxxxxxxxx>
- Date: Sat, 25 Feb 2006 02:37:58 GMT
Daniel Parker wrote:
Well, in that case, you may as well use this one.
class Singleton {
static Singleton instance = new Singleton();
Singleton getInstance() {return instance;}
int flag;
int input;
int output;
void setFlag(int flag) {this.flag = flag;}
int getFlag() {return flag;}
void setInput(int input) {this.input = input;}
int getInput() {return input;}
void setOutput(int output) {this.output = output;}
int getOutput() {return output;}
}
void main(String[] args) {
Singleton.getInstance().setFlag(7);
Singleton..getInstance().setInput(3);
doSomething();
}
void doSomething() {
if (Singleton.getInstance().getFlag() == 2) {
int x = Singleton.getInstance().getInput();
Singleton.getInstance().setOutput(x+20);
}else if (Singleton.getInstance().getFlag() == 7) {
int x = Singleton.getInstance().getInput();
Singleton.getInstance().setOutput(x+29);
}
}
Sigh. This brings back memories of "Bob". Bob didn't like to pass
parameters. Bob liked global flags that changed what functions did. Bob
didn't like "else". Bob wrote in C and assembly on PC's with DOS
extenders, and when you'd call one of his functions to say, calculate a
bond price, the printer would print some hex characters, or things of that
sort. Everyday I would come in and remove a little bit of Bob.
I'm sorry, Daniel. I didn't know.
I hope you are recovering.
--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
.
- References:
- Re: Can use of singletons denote poor project design?
- From: Daniel Parker
- Re: Can use of singletons denote poor project design?
- From: Phlip
- Re: Can use of singletons denote poor project design?
- From: Daniel Parker
- Re: Can use of singletons denote poor project design?
- From: Andrew McDonagh
- Re: Can use of singletons denote poor project design?
- From: Daniel Parker
- Re: Can use of singletons denote poor project design?
- From: Phlip
- Re: Can use of singletons denote poor project design?
- From: Daniel Parker
- Re: Can use of singletons denote poor project design?
- Prev by Date: Re: Can use of singletons denote poor project design?
- Next by Date: Re: software architecture/design question
- Previous by thread: Re: Can use of singletons denote poor project design?
- Next by thread: Re: Can use of singletons denote poor project design?
- Index(es):
Relevant Pages
|