• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting a variable in constructor in 90+ classes

 
Amaru Shakur
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok so i have 90 plus classes where i want to set a variable int id=-1, in every constructor. there has to be a smarter way to do this than by hand. any ideas?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take five times the amount of time it'd take to do it by hand to write a program to do it for you?
 
Eric Weinberg
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Bear mentioned, writing a program to automate this is probably the way to go.

That said, this situation smells a little like a design issue. Is this behavior that all classes share? If so, should it be pulled up into a super or extracted out into it's own class/interface?

Also, aren't you going by Machiavelli now?
[ July 21, 2008: Message edited by: Eric Weinberg ]
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, aren't you going by Machiavelli now?


I was just about to mention that the moderators might not be aware that this is obviously a ficticiuos name
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Weinberg:
As Bear mentioned, writing a program to automate this is probably the way to go.
Actually, I was advocating nothing of the kind. Guess the sarcasm was lost.

The real question is: why? As Eric pointed out, red flags are waving!
[ July 21, 2008: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Garrett Rowe:
I was just about to mention that the moderators might not be aware that this is obviously a ficticiuos name

We are.

"Tupac Amaru Shakur", please check your private messages for an important administrative matter.
 
Eric Weinberg
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Actually, I was advocating nothing of the kind. Guess the sarcasm was lost.


Ha, my mistake!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic