This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Can you make "type" be an object (a Typesafe Enum perhaps) and move the behaviour that differs into it, calling it polymorphically from the loop?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: May 31, 2004
Enums are in Java 1.5 correct? I can't use that as the server is still on 1.4.
If I was doing this I would probably use a switch / case type of structure switching on an int type. Those table driven switch structures are pretty fast. With 20 datagrid types a switch would cut out a lot of if statements. Bill [ June 17, 2005: Message edited by: William Brogden ]
Originally posted by Stefan Wagner: To switch, it would be sufficient, to have Datagrid.TEST_TYPE be of type int. Thousands of records doesn't sound much, so I wouldn't expect much performance difference.
The advantage of the Typesafe Enum pattern is better flexibility - especially if you need to have more than one switch over the same enum.