Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: StatsTable object Date: Mon, 12 Sep 2011 12:59:08 -0400 Organization: A noiseless patient Spider Lines: 43 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:55:21 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="Z+UYWCPnTu4kxHsUACWmFQ"; logging-data="11783"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gdCcCmtbMPVZ4T1k/Nj9XBMy4BHzxecI=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20110818 Icedove/3.0.11 In-Reply-To: Cancel-Lock: sha1:gy4yVxaSqGBlkv8XZsvDT71b4Yw= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7899 On 09/12/2011 12:03 PM, markspace wrote: > 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 In some case it might be to represent the table as a collection of column class instances. > 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()... > }