Re: when is it apt to use classes in preference to only arrays and lists
- From: Neil Madden <nem@xxxxxxxxxxxxx>
- Date: Fri, 30 Sep 2005 16:41:09 GMT
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 .
- References:
- Prev by Date: Re: Image transparency on a disabled button
- Next by Date: Re: retrieving line number in case of error - "simple debugger"
- Previous by thread: Re: when is it apt to use classes in preference to only arrays and lists
- Next by thread: accessing tree nodes
- Index(es):