🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #849

Re: Trouble accessing values in a 2D array

#849
From: Tim Cross
Date: Fri, 12 May 2000 00:00
27 lines
1817 bytes
"Paul Murray" <pmurray@nospam.bigpond.com> writes:
[snip]
 
> On a more general note, you might be better off using the Collections API
> rather than explicitly putting things in arrays. If you do that, you may as
> well use a class for a floating-point XY coord. This allows you to attach
> methods etc. java.util has integer Point and Dimension classes - why not
> model your floating-point classes on those?
> 
I think Paul is spot on here with this advice. Create your own classes
to represent your coordinates and this will give you much better data
encapsulation. As Paul points out, it will also allow you to associate
methods with this data. For example, you might be able to add a
distance method to your coord class which, when passed another coord
object returns the distance/metric between the two points etc. There
is also less chance of your system becomming inconsistant which could
happen if one of your arrays is updated and the other isn't etc. 

Tim

 

-- 
Tim Cross
NorthNet Internet Services
mailto:tcross@northnet.com.au
phone:+61 2 6772 5973
Technical Details
Message-ID: <m3aehwgmco.fsf@tim.northnet.com.au>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <39189457.3527647@news.melbpc.org.au> <8fbd5b$kbd$1@nnrp1.deja.com> <K3uS4.8857$X4.17863@newsfeeds.bigpond.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d6db,1002517bab792639
X-Google-Attributes: gid10d6db,public
From: Tim Cross <tcross@northnet.com.au>
Subject: Re: Trouble accessing values in a 2D array
Date: 2000/05/12
Message-ID: <m3aehwgmco.fsf@tim.northnet.com.au>
X-Deja-AN: 622479676
Sender: tcross@tim.northnet.com.au
References: <39189457.3527647@news.melbpc.org.au> <8fbd5b$kbd$1@nnrp1.deja.com> <K3uS4.8857$X4.17863@newsfeeds.bigpond.com>
X-Complaints-To: abuse@telstra.net
X-Trace: nsw.nnrp.telstra.net 958122812 203.57.24.28 (Fri, 12 May 2000 19:13:32 EST)
Organization: Customer of Telstra Big Pond Direct
NNTP-Posting-Date: Fri, 12 May 2000 19:13:32 EST
Newsgroups: aus.computers.java