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


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

Re: BlueJ don't know what i did wrong

From Arved Sandstrom <asandstrom2@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: BlueJ don't know what i did wrong
References (14 earlier) <3a2dnXBuTbOY4rHMnZ2dnUVZ8iWdnZ2d@bt.com> <0I%Ws.96474$Ln.24770@newsfe22.iad> <672dncokKZ13AbHMnZ2dnUVZ8oadnZ2d@bt.com> <DtlXs.167113$EO2.133976@newsfe04.iad> <PYednV_FAPpyZ7DMnZ2dnUVZ7oKdnZ2d@bt.com>
Message-ID <lszXs.40705$BV7.24274@newsfe24.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2013-02-27 22:40 -0400

Show all headers | View raw


On 02/27/2013 08:24 AM, lipska the kat wrote:
> On 27/02/13 10:45, Arved Sandstrom wrote:
>> On 02/26/2013 07:30 AM, lipska the kat wrote:
>>> On 26/02/13 09:59, Arved Sandstrom wrote:
>>>> On 02/26/2013 05:23 AM, lipska the kat wrote:
>>>> [ SNIP ]
>>>>
>>>>> 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
>>>> [ SNIP ]
>>>>
>>>>>
>>>>> lipska
>>>>>
>>>> A deque (double ended queue) is a queue generalization. Despite the
>>>> name, a deque is not a queue, but a queue is a deque.
>>>
>>> You have this the wrong way round I'm afraid.
>>> A Deque 'is a' Queue because it extends Queue, you can call Queue
>>> methods on Deque but you cannot call Deque methods on Queue.
>>> A Queue is most definitely NOT a Deque.
>>>
>>> These are first year comp sci concepts really.
>> [ SNIP ]
>>
>> You want to read up on generalization and specialization.
>
> On the other hand and discussing C++;
>
> http://www.brpreiss.com/books/opus4/html/page158.html
>
> Specialization
> The more general abstraction is the base class and the restricted
> abstraction is the derived class. E.g., when using specialization we
> would derive the class Queue from the class Deque thus:
> class Queue : public Deque { ... };
> The Queue class interface should restrict access to only those base
> class member functions that are appropriate.
>
> Generalization
> The more restricted abstraction is the base class from which the more
> general abstraction is derived. E.g., when using generalization we would
> derive the class Deque from the class Queue thus:
> class Deque : public Queue { ... };
> The Deque class inherits and generalizes the interface of the Queue class.
>
> appears to be at odds with my earlier assertion
>
> So, does either definition make your assertion
>
> "a deque is not a queue, but a queue is a deque"
>
> true?
>
> No it does not
>
> In the Java programming language, and where Deque extends Queue
>
> a Deque *is* a Queue
>
> and
>
> a Queue *is not* a Deque
>
> regardless of which definition of Specialization and Generalization you
> use.
>
> lipska
>
I'm happy with the definition that for example Knuth or Sedgwick use 
(and about a million other people), where a deque is called a 
generalization of a queue or a stack. The reason a deque is called a 
generalization of a queue or a stack is because it is in fact more 
general than a queue or a stack, and combines features of both.

Since a whole raft of CS authorities and other programming commentators 
are happy to call the deque a generalization of a queue or stack when 
writing about data structures, I'm pretty happy to accept this as a 
definition.

Don't get Java interface implementation aka UML realization mixed up 
with generalization. Deque is a generalization of Queue and Stack 
because it has characteristics of both; that's why you can use a Deque 
as either a Queue or a Stack. The business of Java interface Deque 
extending Java interface Queue, since doing things like that is the 
closest thing that Java has to multiple inheritance, is actually 
generalization, where Queue is the specialization of Deque.

AHS

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