Prev: TYPE_SCROLL_SENSITIVE
Next: parsing dates in a string
From: Simon Brooke on 28 Jun 2010 06:50 On Mon, 28 Jun 2010 00:32:41 -0700, Roedy Green wrote: > On 27 Jun 2010 21:55:04 GMT, Simon Brooke <stillyet+nntp(a)googlemail.com> > wrote, quoted or indirectly quoted someone who said : > >>Is there any way in which both can be satisfied? > > Eiffel has a renaming feature to resolve such conflicts, but within Java > I think you are stuck. > > Do you really want your object to behave directly as both a LinkedList > and a TierMap? That sounds like a very weird duck. LinkedList is a > detail of implementation, not likely something you want your clients to > fiddle with directly. No, it doesn't need to behave like a linked list at all, except that the caller needs to be able to add and remove tiers. In fact, a stack might be a better implementation than a linked list - the caller does not need to have direct access to lower level tiers. > So create a class that does not extend LinkedList, but rather has > private field pointing to one. You can wrap some methods to fiddle with > the LinkedList externally if necessary. Looks like that will have to be the solution. Thanks. (oh, and thanks to everyone else who responded). Simon -- ;; Semper in faecibus sumus, sole profundam variat
From: Simon Brooke on 28 Jun 2010 14:23 On Mon, 28 Jun 2010 08:18:27 -0400, Lew wrote: > Roedy Green wrote: >>> Do you really want your object to behave directly as both a LinkedList >>> and a TierMap? That sounds like a very weird duck. LinkedList is a >>> detail of implementation, not likely something you want your clients >>> to fiddle with directly. > > Simon Brooke wrote: >> No, it doesn't need to behave like a linked list at all, except that >> the caller needs to be able to add and remove tiers. In fact, a stack >> might be a better implementation than a linked list - the caller does >> not need to have direct access to lower level tiers. > > This proves Roedy's point beautifully. If you do expose the 'List' (let > alone 'LinkedList') detail of implementation, you commit to that as part > of the public contract and cannot easily change to 'Stack' when you > realize that it would improve things. Keep that part hidden as > suggested. Good point. Thanks. -- ;; Semper in faecibus sumus, sole profundam variat
|
Pages: 1 Prev: TYPE_SCROLL_SENSITIVE Next: parsing dates in a string |