For Programmers: Free Programming Magazines  


Home > Archive > Tcl > September 2005 > Re: when is it apt to use classes in preference to only arrays and









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: when is it apt to use classes in preference to only arrays and
Neil Madden

2005-09-30, 7:00 pm

vikas wrote:
> hey i am working on a project in which i will be requiring plenty of
> different parameters to be associated with similar objects. what is a
> better idea, to use multidimentional arrays or classes?
>


Well, "it depends" is the usual answer. Generally, though, unless you have a
compelling reason not to (an unhealthy preoccupation with performance, for
instance :-), then I would suggest separating interface from implementation and
designing an API for manipulating your data which is not dependent on the
underlying implementation. Of course, with classes you get this anyway (or
should do, at least). However, if you design the API right then the same can be
achieved with arrays and procs, which gives you flexibility to choose. I would
fairly strongly advise against passing around "raw" arrays, as then it would be
much more difficult to change the implementation. If you're willing to use 8.5,
then you also get dicts as another possible implementation.

-- Neil
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com