NNTP-Posting-Date: Mon, 25 Feb 2013 13:54:26 -0600 Date: Mon, 25 Feb 2013 19:54:22 +0000 From: lipska the kat <"nospam at neversurrender dot co dot uk"> Organization: Trollbusters 3 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: BlueJ don't know what i did wrong References: <638ed624-9eba-44eb-bcbf-68466e5bb5f1@googlegroups.com> <42d76fca-d365-4030-ae8c-07a806eab87c@googlegroups.com> <1wtai7dd80h80$.6rbtwoyou3gh.dlg@40tude.net> <5q6dnc3pF_HJzLfMnZ2dnUVZ7s-dnZ2d@bt.com> <77afaabf-ec0f-46d6-b3ea-d8f186dbf7e4@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Lines: 45 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-z4bCW69WNXC/+AT6R/Zw2NzhZAe7zkddWsZTJGRLaGHa+mPpikFEzpFClPDp3LP3cnX0WKkydexNNxG!BNgA85Nsd4ThrEo4C8es3aOViSti1k3nYrZYQNJLbNt0NLqfnBf+ded/o8uxg/j2fMyv7Nqg0q0= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3578 Path: csiph.com!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail Xref: csiph.com comp.lang.java.programmer:22512 On 25/02/13 18:52, John B. Matthews wrote: > In article, > lipska the kat<"nospam at neversurrender dot co dot uk"> wrote: > >> On 25/02/13 12:50, John B. Matthews wrote: >>> In article, >>> lipska the kat<"nospam at neversurrender dot co dot uk"> wrote: >>> >>>> >>>> >>>> >>>> >>>> Stack s = new Stack() >>>> ... >>>> >>> >>> Please don't recommend raw types for new code, and don't recommend >>> an API that says explicitly, "A more complete and consistent set of >>> LIFO stack operations is provided by the Deque interface and its >>> implementations, which should be used in preference to this class." 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. If you are reading someone else's code and you see Stack s = new Stack(); you know EXACTLY what to expect. What are you to expect when you see a Deque ... could be anything. Can you give me one good reason to use a Deque instead of a Stack when a stack is what I want apart from "because the documentation says so" lipska -- Lipska the Kat©: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun