Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: StatsTable object Date: Mon, 12 Sep 2011 09:03:48 -0700 Organization: A noiseless patient Spider Lines: 37 Message-ID: References: <9ac3f834-0633-434c-86b0-49ed543f3e81@z18g2000yqb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 12 Sep 2011 16:03:50 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="22100"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Kw6UcyG98lkT8F3aJpitgw/egnn5TlRI=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 In-Reply-To: <9ac3f834-0633-434c-86b0-49ed543f3e81@z18g2000yqb.googlegroups.com> Cancel-Lock: sha1:uh/IHNvbtPjMNEyeIQoLEyoENdc= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7896 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; ... don't need "rows" use playerStats.getSize() ... columns: use getPropertyCount()... }