Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #7896
| From | markspace <-@.> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: StatsTable object |
| Date | 2011-09-12 09:03 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <j4lah6$lik$1@dont-email.me> (permalink) |
| References | <9ac3f834-0633-434c-86b0-49ed543f3e81@z18g2000yqb.googlegroups.com> |
On 9/12/2011 1:23 AM, bob wrote:
> What do you all think of this representation? I think it would be
> better if it had a more 2-dimensional feel, but I don't want to
> complicate things.
I don't like it. I think it would be better to represent the rows as
classes, and then compose the object as a collection of those objects.
I know this sounds like a bit of extra work, but in the long run it's
probably better.
For example, if you wanted to use a JTable, which is a table for GUI
display, having the actual types as ints, double, etc. instead of
strings would be a big advantage because the default display/editing
will use those types and "do the right thing" in many cases.
Something like:
public class PlayerStats {
String name;
int touchdowns;
double yardsRushing;
double yardsPassing;
... getters/setters...
public int getPropertyCount() { return 4; }
public int getPropertyNames() {
return new String[] { "Name","Touchdows","Yards Rushing",
"Yards Passing", };
}
public class StatsTable {
ArrayList<PlayerStats> playerStats;
... don't need "rows" use playerStats.getSize()
... columns: use getPropertyCount()...
}
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
StatsTable object bob <bob@coolgroups.com> - 2011-09-12 01:23 -0700
Re: StatsTable object Jeff Higgins <jeff@invalid.invalid> - 2011-09-12 10:00 -0400
Re: StatsTable object Robert Klemme <shortcutter@googlemail.com> - 2011-09-12 18:53 +0200
Re: StatsTable object Jeff Higgins <jeff@invalid.invalid> - 2011-09-12 13:09 -0400
Re: StatsTable object Jeff Higgins <jeff@invalid.invalid> - 2011-09-12 13:23 -0400
Re: StatsTable object markspace <-@.> - 2011-09-12 09:03 -0700
Re: StatsTable object Jeff Higgins <jeff@invalid.invalid> - 2011-09-12 12:59 -0400
Re: StatsTable object markspace <-@.> - 2011-09-12 09:58 -0700
Re: StatsTable object Lew <lewbloch@gmail.com> - 2011-09-12 15:30 -0700
Re: StatsTable object Robert Klemme <shortcutter@googlemail.com> - 2011-09-12 18:52 +0200
Re: StatsTable object Knute Johnson <nospam@knutejohnson.com> - 2011-09-12 10:17 -0700
Re: StatsTable object Robert Klemme <shortcutter@googlemail.com> - 2011-09-12 19:19 +0200
Re: StatsTable object Arne Vajhøj <arne@vajhoej.dk> - 2011-09-12 19:28 -0400
Re: StatsTable object Arne Vajhøj <arne@vajhoej.dk> - 2011-09-12 19:30 -0400
csiph-web