Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #22523

Re: BlueJ don't know what i did wrong

Date 2013-02-26 09:23 +0000
From lipska the kat <"nospam at neversurrender dot co dot uk">
Organization Trollbusters 3
Newsgroups comp.lang.java.programmer
Subject Re: BlueJ don't know what i did wrong
References (9 earlier) <nospam-EC6CD9.07503725022013@news.aioe.org> <PqydnQ_Wh-MT9bbMnZ2dnUVZ8tGdnZ2d@bt.com> <nospam-7D0581.13524425022013@news.aioe.org> <Z7adnQWfyf7vXLbMnZ2dnUVZ7tWdnZ2d@bt.com> <512c2745$0$289$14726298@news.sunsite.dk>
Message-ID <3a2dnXBuTbOY4rHMnZ2dnUVZ8iWdnZ2d@bt.com> (permalink)

Show all headers | View raw


On 26/02/13 03:08, Arne Vajhøj wrote:
> On 2/25/2013 2:54 PM, lipska the kat wrote:
>> On 25/02/13 18:52, John B. Matthews wrote:
[snip]
>>
>> Why? why use a Deque instead of a Stack? ... because the documentation
>> says so? ... A Stack is an abstraction, it's a very widely understood
>> abstraction, everyone who has ever read a book on software knows what a
>> stack is. push, pop, peek, they are Stack methods, you don't need
>> anything else for a Stack, even peek is questionable. Providing a method
>> to add something to the bottom of a Stack doesn't make sense in terms of
>> the 'stackness' of a Stack. It just adds meaningless and unneeded
>> complexity and confusion, particularly for a beginner to Java.
>
> You are aware that Stack<> provides elementAt, insertElementAt and
> removeElementAt?

Y'know what Arne, you are quite predictable, it was a toss up between 
you and Lew as to who would point that out first ...  ding ! we have a 
winner.

Vector provides the methods you mention, not Stack ... and before you go 
into a long diatribe about inheritance you can save your breath, I'm 
fully aware of those implications.

If you use Vector methods on a Stack then you are intentionally breaking 
the contract of Stack. This is simply poor coding practice, it makes 
your code harder to read and maintain and exposes a confused 
understanding of abstraction. If you want Vector methods use a Vector, 
if you want a Stack, use a Stack. It constantly amazes me that 
supposedly experienced developers don't understand this simple, 
fundamental rule of Object Oriented Software Design.

What's the contract of Deque ... a double ended queue?
That in itself breaks the (humanly acceptable) contract of Queue.
If a Queue is double ended it's not (conceptually) a Queue is it?

Stack = LIFO
Queue = FIFO

Anything else isn't

Maybe it would have been better if a Stack had been implemented by 
Composition WITH Vector rather by extension OF Vector ...

But if we have inheritance why not use it eh?
(that's a rhetorical question).

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

BlueJ don't know what i did wrong BlueJguywithoutskill <marvin.radke@htp-tel.de> - 2013-02-22 06:03 -0800
  Re: BlueJ don't know what i did wrong Joerg Meier <joergmmeier@arcor.de> - 2013-02-22 15:55 +0100
  Re: BlueJ don't know what i did wrong marvin.radke@htp-tel.de - 2013-02-22 07:13 -0800
    Re: BlueJ don't know what i did wrong Joerg Meier <joergmmeier@arcor.de> - 2013-02-22 16:24 +0100
      Re: BlueJ don't know what i did wrong marvin.radke@htp-tel.de - 2013-02-22 07:31 -0800
      Re: BlueJ don't know what i did wrong Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-02-22 10:50 -0500
  Re: BlueJ don't know what i did wrong markspace <markspace@nospam.nospam> - 2013-02-22 10:43 -0800
  Re: BlueJ don't know what i did wrong marvin.radke@htp-tel.de - 2013-02-24 02:27 -0800
    Re: BlueJ don't know what i did wrong Joerg Meier <joergmmeier@arcor.de> - 2013-02-24 14:54 +0100
      Re: BlueJ don't know what i did wrong marvin.radke@htp-tel.de - 2013-02-24 06:15 -0800
    Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-24 15:04 +0000
    Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-24 16:29 +0000
      Re: BlueJ don't know what i did wrong Joerg Meier <joergmmeier@arcor.de> - 2013-02-24 18:21 +0100
        Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-24 17:43 +0000
          Re: BlueJ don't know what i did wrong Joerg Meier <joergmmeier@arcor.de> - 2013-02-24 20:04 +0100
            Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-24 19:24 +0000
              Re: BlueJ don't know what i did wrong marvin.radke@htp-tel.de - 2013-02-25 01:52 -0800
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-25 11:10 +0000
                Re: BlueJ don't know what i did wrong "John B. Matthews" <nospam@nospam.invalid> - 2013-02-25 07:50 -0500
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-25 13:35 +0000
                Re: BlueJ don't know what i did wrong "John B. Matthews" <nospam@nospam.invalid> - 2013-02-25 13:52 -0500
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-25 19:54 +0000
                Re: BlueJ don't know what i did wrong Lew <lewbloch@gmail.com> - 2013-02-25 14:26 -0800
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-26 09:08 +0000
                Re: BlueJ don't know what i did wrong Arne Vajhøj <arne@vajhoej.dk> - 2013-02-25 22:05 -0500
                Re: BlueJ don't know what i did wrong Arne Vajhøj <arne@vajhoej.dk> - 2013-02-25 22:08 -0500
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-26 09:23 +0000
                Re: BlueJ don't know what i did wrong Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-26 05:59 -0400
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-26 11:30 +0000
                Re: BlueJ don't know what i did wrong Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-27 06:45 -0400
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-27 11:58 +0000
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-27 12:24 +0000
                Re: BlueJ don't know what i did wrong Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-27 22:40 -0400
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-28 08:53 +0000
                Re: BlueJ don't know what i did wrong Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-28 17:14 -0400
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-03-01 08:45 +0000
                Re: BlueJ don't know what i did wrong markspace <markspace@nospam.nospam> - 2013-02-26 08:33 -0800
                Re: BlueJ don't know what i did wrong Arne Vajhøj <arne@vajhoej.dk> - 2013-02-25 22:19 -0500
                Re: BlueJ don't know what i did wrong Arne Vajhøj <arne@vajhoej.dk> - 2013-02-25 22:02 -0500
                Re: BlueJ don't know what i did wrong marvin.radke@htp-tel.de - 2013-02-25 09:54 -0800
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-25 18:25 +0000
                Re: BlueJ don't know what i did wrong Joerg Meier <joergmmeier@arcor.de> - 2013-02-26 16:13 +0100
                Re: BlueJ don't know what i did wrong lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-26 16:40 +0000
                Re: BlueJ don't know what i did wrong Joerg Meier <joergmmeier@arcor.de> - 2013-02-26 18:19 +0100
                Re: BlueJ don't know what i did wrong markspace <markspace@nospam.nospam> - 2013-02-25 08:34 -0800
    Re: BlueJ don't know what i did wrong Lew <lewbloch@gmail.com> - 2013-02-24 12:38 -0800

csiph-web