Code Comments
Programming Forum and web based access to our favorite programming groups.Alex.From.Ohio.Java@gmail.com writes: >Thinking In Java is good one. Recently someone claimed that "Thinking in Java 3", contained this sentence: |If you're defining an anonymous inner class and want to use an |object that's defined outside the anonymous inner class, the |compiler requires that the argument reference be final, like |the argument to dest(). Here, Eckel writes: »object that's defined«. Objects, however, are not "defined", they are /created/ at run-time. Names of reference variables are being /declared/ in the source text, not "defined". http://java.sun.com/docs/books/jls/...ments.html#5920 Then, he continues to write »argument reference be final«. This might intend to say that a reference parameter was declared with "final". "final" is not an attribute of a, /reference/, but of a variable. However, this is not about /arguments/ (the reference arguments do not have to be declared "final" here), but about /parameters/. The distinction between these two Java terms seems to be unknown to Eckel. parameter: http://java.sun.com/docs/books/jls/...ames.html#6.8.7 arguments: http://java.sun.com/docs/books/jls/...ions.html#15.12 He also writes: »the compiler requires«. It might be the case that the compiler of Mr. Eckel indeed requires this, but he should teach a language instead of an implementation, so it might be preferable to write "the language specification requires«. Also, anonymous inner classes are not being /defined/ in Java, as Eckel writes at the beginning of the quotation, but they are being /declared/. Moreover, "anonymous" is an unnecessary restriction, because the assertion is valid for /all/ inner classes. Someone learning by this sentence thus needs to learn anew at another time that this is also valid for non-anonymous inner classes, or he might believe erroneously for an indetermined amount of time, that it is only valid for anonymous inner classes. Is there a way to improve the sentence? One attempt by me: A parameter to be used within an inner class of its method needs to be declared »final«. Even the Java Language Specification itself is easier to read than Eckel (and of course, much more correct): Any local variable, formal method parameter or exception handler parameter used but not declared in an inner class must be declared final. http://java.sun.com/docs/books/jls/...sses.html#8.1.3 All the reported faults have been found by me within a single sentence chosen at random (I did not read the book, but discovered the sentence in another posting, claiming to quote this sentence from "Thinking in Java".) If one extrapolates this error quotient to the whole TIJ, it gives a horrid impression. Some books might sell chiefly because the buyer wants to express agreement with their title. When one is learning a foreign language one does not want to think everything in English first and then painfully translate it word-by-word. So one might choose "Thinking in Java" instead of a garden-variety "Introduction to Java", because one longs for the promise given by its title, not suspecting that the author Eckel himself might be far from "thinking in Java".
Post Follow-up to this messageStefan Ram wrote: > All the reported faults have been found by me within a single > sentence chosen at random (I did not read the book, but I think we should all be wary of drawing conclusions from a single data point. However, Stefan's experience mirrors my own. I've tried a couple of Bruce Eckel's books, including a read-through of Thinking in Java some years ago, and I found them pretty poor overall, including the Java book. There are better resources available. Besides what's been mentioned here already (Sun's tutorial and the Javapassion website), I like _Learning Java_ published by O'Reilly. It's a bit thick for someone brand new, and it teaches Java, not programming, but it's generally factually correct, it's examples make sense, and it does hit all the important parts of the API, usually with an example that helps the API make sense. In particular it has a very good explanation of the nitty-gritty of generics. Also, the Javadoc is an excellent resource, although very hard on the beginner. Search for Java classes with Google and a string like "java classname se 6" to get the latest version. I think I should start adding the JLS to my list of references, just for completeness. It's actually fairly easy to read, most of the time.
Post Follow-up to this messageMark Space wrote: > Also, the Javadoc is an excellent resource, although very hard on the > beginner. Search for Java classes with Google and a string like "java > classname se 6" to get the latest version. I think I should start > adding the JLS to my list of references, just for completeness. It's > actually fairly easy to read, most of the time. In order to be a decent Java programmer, much less a master, one will have t o become facile with the API Javadocs and the JLS. One might as well begin th e adjustment process immediately. <http://java.sun.com/javase/6/docs/api/> <http://java.sun.com/docs/books/jls/...html/j3TOC.html> Javadoc is a tool, too. Use it to document one's own code. <http://java.sun.com/javase/6/docs/t...is/javadoc.html> also s=solaris=windows=. -- Lew
Post Follow-up to this messageLew wrote: > Javadoc is a tool, too. Use it to document one's own code. Yes, that's true. I'm at a lost for a pithy name for Sun's Java documentation. While Javadoc is a tool, a lot of folks do seem to refer to the main documentation as "the Javadoc." Maybe that's not a great idea, but it seldom seems to cause confusion. Hmmm, maybe "Java doc" (with a space) would be a better phrase for Sun's online documentation....
Post Follow-up to this messageMark Space wrote: > I'm at a lost for a pithy name for Sun's Java > documentation. While Javadoc is a tool, a lot of folks do seem to refer > to the main documentation as "the Javadoc." Maybe that's not a great > idea, but it seldom seems to cause confusion. > > Hmmm, maybe "Java doc" (with a space) would be a better phrase for Sun's > online documentation.... The people have already spoken, and it's "the Javadocs". I don't hold out much hope for you to successfully buck the social momentum. -- Lew
Post Follow-up to this messageOn Thu, 20 Mar 2008 11:25:20 -0700, Mark Space wrote: > Besides what's been mentioned here already (Sun's tutorial and the > Javapassion website), I like _Learning Java_ published by O'Reilly. I really like: http://www.oreilly.com/catalog/hfjava2/ It seems silly, but their silly technique of, well, silliness, works. I only wish they would write a book a w! I read the first edition, but I'm sure that the second edition is better. Does it cover generics, I wonder? -Thufir
Post Follow-up to this messageOn Thu, 20 Mar 2008 00:58:09 -0700, Santosh Krishnan wrote: > Yes we have been prescribed a textbook called SL-275 but it has only one > complete example. Everything else is just code snippets. Unfortunately > the teacher isn't very good too. But thanks for your suggestion, Sun's > tutorial seems the best option at the moment. I'll be taking http://www.bcit.ca/study/outlines/comp2611200830 in just a few days! and the textbook is: Introduction to Java Programming: Fundamentals First (Paperback) by Y Daniel Liang (Author) # Paperback: 704 pages # Publisher: Prentice Hall; 6 edition (Jul 11 2006) # Language: English # ISBN-10: 0132237385 # ISBN-13: 978-0132237383 http://www.amazon.ca/Introduction-J...amentals-First/ dp/0132237385/ref=sr_1_1?ie=UTF8&s=books&qid=1206746314&sr=1-1 I sure hope that my experience is different! Still waiting for the darn book in the mail. (Bookstores are such a scam at college, thankfully there's Amazon -- assuming the darn thing ever arrives.) -Thufir
Post Follow-up to this messageCore Java By Cay Horstmann and Gary Cornell http://groups.google.com/group/java...eloupment?hl=en
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.