From: Eric B. <er...@go...> - 2006-09-24 15:04:53
|
Forwarded to the list. -------- Original Message -------- Subject: Re: [gobo-eiffel-develop] geant command line parsing Date: Sun, 24 Sep 2006 17:02:24 +0200 From: "Bernd Schoeller" <ber...@in...> Organization: ETH Zurich To: "Eric Bezault" <er...@go...> References: <op....@ar...> <451...@go...> On Sun, 24 Sep 2006 16:38:03 +0200, Eric Bezault <er...@go...> wrote: > But determining the right type to use to declare `parameters' > in AP_STRING_OPTION is an interesting problem in general. > Should we be as specific as possible? In that case we should > probably choose DS_ARRAYED_LIST. Or should we be more abstract? > In that case, what ancestor do we choose? Why stop at DS_LIST? > What about DS_LINEAR (which in fact might be better in the > interface because it gives a read-only view), or should we go > even higher in the inheritance hierarchy? Personally in my code > I always use the most specific type. I found it convenient so > far, but it is true that most of the time it puts in the interface > of the class more information than the client should actually know. You are right, this is a fundamental problem with information hiding. Contracts do not contain information about algorithmic complexity. I had numerous problem with this while trying to develop a general library for graph data structures. Here, choosing the wrong access pattern can have even worse effects on the efficiency of algorithms than in the case of linear lists. It is a real show stopper. I have no final answer, but I should at least be consequent: either choosing DS_ARRAYED_LIST or DS_LINEAR instead of the intermediate DS_LIST. Currently, I also tend towards adopting your decision of revealing the implementation to the outside by returning DS_ARRAYED_LIST. Bernd |