Beginning Java Objects
Coming to Java from ColdFusion and ASP has been a long and arduous journey. Those languages lack the strong typing, the formal structure, and the incredible power that Java offers. In the course of grappling with concepts completely foreign to those languages, I have purchased and read many books. I've read Thinking in Java, Java: How to Program, and Java in a Nutshell, all in a futile effort to learn the language in a systematic and useful way. Each book came up short in the teaching department: one covered Java too abstractly, another too concretely. Reading these books' turgid style was a surefire turn-off to the language. After a while, I realized that the problem wasn't totally with me -- that these books were not designed for newcomers to the language.
I then came across two books that changed my view of Java introductory texts completely. Both Beginning Java Objects (hereafter BJO) and Head First Java (hereafter HFJ) take beginner-centric approaches to instruction. They both seem to understand that reading computer language overviews is a necessary evil and that most books fail to connect with their readers. They both take active roles in guiding the reader through Java, though their executions are wildly different.
Two Different Styles The fundamental difference between the two books is teaching style: they're both obviously the products of serious pedagogical thought. BJO's pedagogical considerations are understated, while HFJ's are explicit and pronounced. BJO moves the reader from start to finish on a single project, introducing Java syntax and language elements as needed and largely in the final third of the book. HFJ, on the other hand, divides major topics into smaller units interspersed with pictures, diagrams, and tables in order to break up the monotony.The effect of BJO is that each chapter builds on the previous one, thus discouraging browsing through the book haphazardly. This was the first computer book that I have read cover-to-cover, though it took me forever to get through at over 650 pages. It starts with an introduction to objects and object-oriented programming. This first section gets you thinking about the concept of objects, gradually working in the seeds of the book's example project, so that you're thinking about what objects you'll eventually need. The second part involves modeling those objects you deemed necessary in the first part using UML. It's by no means a complete guide to UML, but the author wants you to realize that UML is a vital part of the design phase.
The final part introduces the majority of Java syntax and focuses on implementing those objects you've modeled. First, the author works on a command-line version of a university registration system using the file system to persist data. Finally, she implements a GUI version using Swing that still uses the file system.
HFJ, on the other hand, reads like a computer book version of Alton Brown's cooking show Good Eats. Syntax lessons share the pages with funny anecdotes, cartoonish diagrams, silly exercises, and sidebars of various kinds. Some of the jokes and visual aids will make you groan, but they are, by and large, helpful and not too lighthearted. At first, the style seems like a gimmick but you quickly lose that sense of novelty. The book is organized around 17 topics that the authors think are important. Each chapter only marginally builds on the previous, so skipping around is both possible and suggested. The topics range from the common (objects, polymorphism) to the rare (RMI, sockets, exceptions). There's also an appendix that covers briefly 10 items that didn't quite make the cut for the book but were too important to leave out entirely. If I had to characterize HFJ's teaching style, I would describe it as visual.
Which is Better? So they have different styles, which one should you buy? I think that if you have to choose one or the other, you need to evaluate your learning style. Think back to when you learned your last language or important subject. How did you learn it? Did you systematically follow a tutorial? Or did you come up with an application and learn what you needed as you needed it? I would describe the first method as a hierarchical learning style and the second as a visual learning style. There's much more cognitive psychology here that would better inform such casual definition, but that's beyond this review.For the hierarchical or systematic learner, BJO is the book for you. The author's presentation of an application from start to finish is very well done and the application actually bears a striking resemblance to something that would exist in the real world. The introduction of UML to the design process will warm the cockles of a systematic learner's heart. What's more, the natural progression from one topic to the next will help those learners who need structure and rigor in their instruction. HFJ might strike this type of learner as cutesy and flighty. While it's definitely a more soporific read, you really have a sense that you're learning from every paragraph and page.
The visual learner would probably not get very far into BJO because there's little code to read or practice with until the third part of the book. HFJ is perfect for this type of reader since it encourages flitting about while it entertains your brain into learning. The topics aren't covered as thoroughly as in other books, but that's because the authors are trying to present only what's necessary in order to avoid cranial overload. The book's breezy style makes for very easy reading and I more than once found myself eager with the anticipation I normally reserve for fiction of the page-turner variety. In addition, the book covers some topics, like exception handling, that I hadn't encountered in my introductory Java book adventures and it does so in a very compelling and memorable way. There is an application that is developed over the course of the book, but it's not as well integrated into the book as the one in BJO is. Unlike BJO, this book sometimes leaves you unsure of why you're learning a particular item until later. Often, though, these lapses are addressed in a sidebar they call "There are no dumb questions," but I would have preferred to see more of them.
Anything Left? Neither book, though, is perfect. For example, both books whizzed through some subjects that really deserve more treatment: exception handling in BJO and variable types in HFJ. Also, neither discussed persistence beyond the file system. In the real world, I have a feeling that file-based persistence is one of the least common varieties. I can understand, though, that dealing with JDBC and the like would have increased the lengths of the books as well as their complexity. Finally, neither book did a good job of telling the reader what the next steps in learning Java should be. Java is a huge topic and it is very confusing for the beginner to get a bearing in the Java ocean. Having an expert say "If you're interested in JSP, you should find books on these subjects next, and then these" is of inestimable benefit. Heck, it's even hard to know what areas of Java you might be interested in if your introduction to Java is casual and not demanded by work needs.BJO omits any mention of unit testing your applications, but I think that's largely a shortcoming of having published the book in 2000. HFJ revels in test-driven development and includes writing a test as the second step of the three-part development process. Each code sample includes a test class and the authors stress repeatedly the importance of TDD. Unfortunately, they don't mention JUnita, glaring omission since the two are practically synonymous. Tests are emphasized but the reader isn't shown how to use them effectively. With the value attendant in a test-first development process, these omissions are of serious concern.
Concluding Thoughts These two books combined make for a very solid introduction to Java. Though they take different tacks, I think the categorization of people's learning style into a simple dichotomy is not realistic. People learn through a variety of means, yes, but often that variety is present in an individual. Reading both books will ensure that your learning style is covered as well as reinforcing the basic principles of good Java programming through repetition. There really isn't enough overlap between the two books to make the reading of them both tedious.Once you've read these two books (or just one if you're a cheapskate), you should probably consider moving on to Bruce Eckel's Thinking in Java and perhaps finding a good book on JDBC or Java and XML. Eckel's book covers much of the same ground as these two, but there are some sections in his book that you absolutely must read to progress as a Java programmer (or learn them on your own, of course). Where you go after that is up to you and I would recommend a quick survey of the topics at prominent Java Web sites to see what sort of areas are available.
You can purchase Beginning Java Objects: From Concepts to Code from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
If you're REALLY a cheapskate, you'll convince all of your friends to learn Java. A month later, you'll have every "24 hours", "21 days", "for dummies", etc book ever written about the language.
You can't judge a book by the way it wears its hair.
><));>
er... Java -does- come with a compiler: javac.
It comes with the SDK... javac == java compiler... It compiles into byte code which the virtual machine then handles for whatever platform you are on. There are other specifics obviously, but that is the general idea. Perl and the like however do -not- have compilers as they are an interpreted language... and therefore have interpreters...
Looks like it all depends on if you are more of a visual learner or if you learn more from having hands on the code.
MMORPG Master? Prove Your Worth
any of the nutshell books are horrible to learn from--though i find them invaluable as reference and count 4 behind me right now.
funny alton brown ref.
!(^((ri)|(mp))aa$)
...the incredible power that Java offers...
.NET.
I have been programming Java for about two years, and did not receive any incredible powers. You can make your computer do a bunch of stuff, but most of it is pretty lame and deals with either printing the text or displaying some images. However, Java failed to deliver the promise of being able to walk on water, fly high into the sky, pass through walls and understand any language without an interpreter.
I am switching to
The USAF uses java for several of its apps.
><));>
The topics range from the common (objects, polymorphism) to the rare (RMI, sockets, exceptions).
[rant]
Exceptions are one of the more fundamental (and useful) features of the Java language. Whether or not they are "in your face" (as far as source code is concerned), they exist and have the potential to greatly change the flow of your program. Considering them "rare" is a tremendous disservice to those learning how to use Java in a productive manner. I hope that this is simply the reviewer's choice of language, and not a flaw in the book iteslf.
[/rant]
The problem I've generally had with books about programming languages is that they almost invariably start out with several chapters (anywhere from one to five) dedicated to concepts that either you should already know, or that you should learn elsewhere. If I have a library of 50 computer books, I only want one book that covers object oriented programming concepts, for example. I don't need nor do I want all 50 to cover OOP. Even if I only have a library of 5 books, I'd still rather have only one that covers the basics. That way, I don't have to dig through five different, sometimes conflicting, explanations of the same concepts. Rather than dedicating the first 200 pages of a 600 page book to that and selling for $50, they should cut those pages and sell the 400 page book for $30.
Yes, I understand that beginners need books too, but even they don't need a discourse on object oriented programming every time they buy a Java, C++, or C# book. Why can't we have one or two definitive books covering basics, and get rid of that stuff in the rest of the books?
If they can do it, so can you:
http://www.newtechusa.com/PPI/talent.asp
http://www.welton.it/davidw/
The topics range from the common (objects, polymorphism) to the rare (RMI, sockets, exceptions).
;-)
I think it's a understatement to call exceptions 'rare' though. It's an important part of Java, but may be difficult to fully master. At least in my programs, exceptions are far from rare!
I'm more of a green tea person, myself.
This is not longer true. You can compile perl code.
perldoc perlcompile
http://arhuaco.org/
Sun has assets left?
If you're a C or C++ developer, you probably won't need either of these books - Eckel's Thinking In Java will probably do you just fine, and you can download it for free.
Slightly unrelated question:
I have been writing C# for a while, and would like to get a handle on Java so that I can tap into its larger job market. Can anyone reccomend a good book that can get to the point quickly? I read Core Java over a year ago, but I'm not looking for all of the nuts and bolts anymore. Most books out there go from Java *to* C#, not the other way around.
If this is all you did with Java, you missed its real strength: server-side frameworks. Yes, Java didn't deliver on the client side. But it is excellent on the server side, with frameworks such as Tapestry, Struts, Servlets, J2EE (JBoss). It will be a while before .Net matures in these areas as Java has.
Personally, I've switched to Python for a lot of work, but for team-based enterprise development, Java is the best thing out there. It forces the weaker programmers to follow good programming concepts (such as forced catching of exceptions).
This one is a great addition to the book shelf, you all know how to do certain things Java Objects but this book clarifies nicely why you are actually doing it. Also, it introduces nice advanced Java Object concepts which hardcore OOers might not have come across before.
There is no god
Barnes and noble: $35.99
Amazon: $31.49
The Java language itself is fairly sparse. The collection of libraries that make up the JRE (Java Runtime Environment) is immense. And java is pretty useless until you learn your way around the APIs.
I like the language in general. The exception handling model is good. The standard APIs are rich. The namespace issues are handled well.
Developing in Java is a pain in the ass, however, due to classpath and packaging issues. The various IDEs help somewhat, but they can also obscure these issues and prevent you from learning them. In addition, everyone knows that vi is the one true editor - and vim provides good syntax highlighting too.
Best advice to a budding java developer is learn to use apache Ant right from the start. Using JUnit early on is also a good idea. Doing small projects with Ant and Java is far easier and more informative than doing projects in java alone or in an IDE.
Damn it takes a long time to read that.
Support the GNAA!
Brought to you by the AAHAA (The Anti Andrew Huard Association of America)
That's not too bad... I got brainwashed so bad that I think I've been paid for over a year doing Java work...
"Faith: Belief without evidence in what is told by one who speaks without knowledge, of things without parallel." - A.B.
Yeah, only little nobodies like my employer: GM.
Dumbass.
Andrew? is that you?
I think the guy you replied to was joking... Relax.
> the strong typing, the formal structure, and
> the incredible power that Java offers. In the
> course of grappling with concepts completely
> foreign to those languages, I have purchased
> and read many books.
Incredible powers with ducktape on C(++)? I guess it depends on the direction one's coming from. I came from the direction of C++ and python and I would never describe java as powerful. IMHO, it's a blockish, rigid, boring language with many libraries.
Discovering Common Lisp didn't help me fall in love with java, either. I also lost a lot of respect for static typing recently, gets in the way, and my tests are better at catching errors.
[That said ML's approach to this (static type checking, but no explicit type declarations) is nice.]
have you done it? Is it sweet? Any pointers?
What I'm actually working on doing, if you care, is wrapping an app called dcm4jboss in jython, but I'm still trying to get dcm4jboss working the way I want. I know python and c++ (along with some others) and have read and made small changes to java. From my jython book it looks pretty damn easy.
prepare my dinner - Kitchen
make my bed - Bedroom
bear my children - Bedroom
keep the house clean - OK maybe you are right but, outside of the house, useless
That's still "byte code", which means it's still interpretted not "compiled" in the traditional sense. There are to-native compilers for Java, but their results are not by any means as fast as programs written in C++.
www.bookpool.com $30.50
Nobody, that's who
who's nobody? I guess that would mean everyone uses it.. egg on your face! haha
Then again, instead of seeing that as detracting from the possible good ideas and innovations that could be created or at the very least the understanding of a new slice of the market (which could be 50% if more software, advertising, etc was targetted at them), you probably see this as an opportunity for you to hopefully be one of the few that doesn't loose your job. Sigh. Sorry to sound exasperated. It could be that I am just overworked right now.
I would recommend "On To Java," instead. Easy to read, well documented, short lessons and with all the basic good stuff needed to become a JavaHead!
come on, seriously now.
There's a lot to be said for "Just Java" as an introduction, along with robocode, etc. IBM's Developerworks has a lot of helpful articles ranging from intro to advanced. What I've learned of Java has been from these sources & some of the books mentioned in the review. "Thinking in Java" is excellent.
I'm happy to be an idiot as long as I get to use Java! :-) Ahh, Java.
I realize people are taught to spell by sounding out words, but isn't "ducktape" just a little too much?
"Byte code" is simply machine instructions that your machine can't run. So it is compiled. Native compilation happens at runtime, but is a pretty transparent process since byte code -> native is a pretty straight-forward process. Java hasn't been interpreted in over 6 years.
Javascript + Nintendo DSi = DSiCade
"The Java language itself is fairly sparse. The collection of libraries that make up the JRE (Java Runtime Environment) is immense. And java is pretty useless until you learn your way around the APIs."
Isn't this true of all languages? The power, and usage of C++ is in the libraries. The power of Smalltalk is in the libraries. The power of English is at the library.
"Developing in Java is a pain in the ass, however, due to classpath and packaging issues. The various IDEs help somewhat, but they can also obscure these issues and prevent you from learning them. In addition, everyone knows that vi is the one true editor - and vim provides good syntax highlighting too."
Isn't it the job of a good IDE to take care of such niggling details, as classpath, and packaging?
"Best advice to a budding java developer is learn to use apache Ant right from the start. Using JUnit early on is also a good idea. Doing small projects with Ant and Java is far easier and more informative than doing projects in java alone or in an IDE."
Noted: What do you think of Wrox "Beginning Java 2"?
BestBookBuys shows buy.com selling it for $27.60.
You can go from knowing nothing about Java to programming J2EE systems by following this plan (I'm serious):
Of course, you should be actively engaging with these materials and coding as you go along, or none of this will stick. It took me about ten months, following this lesson plan, to consider myself a J2EE programmer -- and I started at the beginning, knowing nothing but PHP and Perl. I'm now an employed J2EE programmer (becoming a rarity in this country).
This previous school year I took the first year of a two year computer science class (I am part of the first year where the AP exam will be in Java instead of C++ ). I will not be able to take the second year next year because of scheduling conflict but will be able to take it my senior year. Our class left off at advanced math problems being solved by recursion (the Towers of Hanoi problem sticks out in my head.) What would be a good book to review what we learned this year and be prepared for my second year of the class?"
Amazon has it for $4.50 cheaper than bn!!!!
So You Are The Amazon Whore!!!!
Ah, but which basics? The term "object-oriented" means different things to different people. The differences you're seeing in these books are probably caused by this.
Go read this article by Jonathan Rees, and you'll see why Java OO != Smalltalk OO != CLOS OO (to name two models you've probably seen, and one you probably haven't).
To a Lisp hacker, XML is S-expressions in drag.
I found the first edition of this book to be very helpful in becoming proficient in the Java language and standard libraries.
It covers all of the important concepts, really in as much detail as I believe one might want short of looking at the API documentation itself, including many particularities of each that aren't quite so intuitive: types, objects, classes, interfaces, io, threads, collections, reflection, beans, Swing, and more.
Looking at the O'Reilly website, I see that the second edition of the book also includes discussions of regular expressions and NIO, the new higher performance I/O system.
I won't be purchasing the second edition of the book, but if you are new to Java, I believe I can recommend it.
You get an overview of the entire language and the important standard libraries. It provides enough detail that it can often serve as a reference until you feel comfortable using the Java whitepapers and API specifications as your primary reference.
700 pages.
If you don't have a lot of experience with really taking advantage of object orientated concepts and design, and you find yourself using Java more than C/C++, I also recommend Oreilly's, "Java Design Patterns: A Tutorial". It puts much of the content of the original Design Patterns book into a Java context, and gives you numerous detailed and concrete examples of employing these patterns in Java and especially in standard Java scenarios. It provides suggestions for how to tell if you should use a particular pattern, as well as the advantages and disadvantages of each.
I'm certain that reading it will help you produce Java code that is more elegant and more maintainable. It will also help you be more conversant in object orientated design concepts.
And oh yes: avoid implementation inheritance unless you have a very good reason to use it; saving lines of code is not generally such a reason =)
.sig Realistic fines for copyright in
Why does the Slashdot Java icon look like a bucket of steaming poo?
Ah. Never mind.
http://cgisecurity.com/development/java.shtml
If this guy considers exception handling to be a rare occurance in Java, he's got another thing coming when he tries to use just about any part of the Java API.
This is a good review. I liked the reviewers take on the two books and he certainly told me what he liked about the book being reviewed.
He could, perhaps, have told us a bit more what he didn't like.
Tony
My brain absorbs technical manuals like a sponge. I can read a coding reference book and write significant working code in a few hours.
I wish I had the same power to learn human languages that way.
Well, I'm glad that at least UML is covered in that book. Looking over it after buying all the rave reviews, I concluded that it was basically a waste of paper and never left it underneath my couch.
hehe i've been laughing at that for the last five minutes... and i'm at work, damnit!
Having recently completed a physics PhD, I decided to learn how to program more rigorously. As the reviewer suggested, I read Beginning Java Objects followed by Thinking in Java. Having browsed through a few other books before reading BJO, I really think that it is particularly useful at highlighting and explaining the important concepts of OO programming. After reading this book I found that many aspects of Java that previously seemed very confusing were crystal clear and I wondered why I hadn't picked it up sooner.
In Jackie Barker's book she often uses a Student Registration System as an example application. I enjoyed following her thought process in developing this application, and learnt a lot from it.
After reading this book as a basic introduction to Java, I read Thinking in Java and found that I was able to get more from it. It filled in many gaps in my knowledge, and extended many of the ideas presented by Barker.
For anyone wanting to learn Java or OO programming, I highly recommend BJO as a starting point.
Can't find the book you referenced
Oreilly's, "Java Design Patterns: A Tutorial"
on the O'Reilly site - can you provide ISBN or a link?
thanks
Oops, Java Design Patterns is an Addison-Wesley book, not an O'Reilly book.
I read that one through O'Reilly's Safari service (which is great by the way), and hence the point of confusion =)
ISBN: 0-201-48539-7
publisher link: Java Design Patterns
.sig Realistic fines for copyright in
I took a Java class last semester and decided to use Learning Java instead of the course textbook, the abysmal An Intro to Object Oriented Programming with Java (by T. Wu).
I knew I had made the right decision when I looked up the continue statement. The O'Reilly book said 'terminates the current iteration of the innermost loop and evaluates the boolean expression that controls the loop', whereas the Wu textbook said only 'reserved keyword -- do not name a variable continue'(!)
Vino, gyno, and techno -Bruce Sterling
I always amazing me the number of people who think they know something about Java.
.NET is JIT compiled, while Java has moved on from being Iterpreted (MANY years ago) to JIT compilation. It has now moved on even further and uses an advanced optimizing JITTER. Do a search for "Hotspot Whitepaper" to read more) .NET is based HEAVILY on Java and that Java is by far more mature )
Here is a list of the nonsense the typically spout:
1. Java is interpreted and therefore slow. (every heard of Hotspot of JIT). There are numerous (non MS) benchmarks proving that Java is fast.
2. Nobody uses Java.
Wrong again
If this is true who are those millions of people regestered at Java sites??
(just visit http://www.tiobe.com/tiobe_index/index.htm to see that Java ranked number 1)
3. Java is only used to write applets.
(I am a Java programmer and never write applets).
(ever heard of J2EE).
4. Java cannot call native code.
(ever heard of JNI)
5. Microsoft no longer supports Java therefore it is dead.
(This one is really funny, Java programmers don't care about MS. They don't even have to deploy their apps on Windows if they don't want to. Because Java is cross-platform we can simply switch to Linux without recompiling our apps) The only Java support Microsoft ever provided what their ANCHIENT Virtual Machine which only supported the version of Java my grandpa used)
-Java is that anchient version 1.1 I tried a few years back. (The latest version is 1.4.2 and 1.5 will enter beta shortly. You can't even begin to compare these to those old versions in terms of performance or functionality)
-.NET is way better than Java because
a) It is compiled while Java is interpreted
b) It is revolutionary
c) It comes from Microsoft
(a - Nonsense:
(b - Utter nonsense, anyone with a brain can see that
(c - Who cares about MS)
When you say "at runtime" do you mean as the program loads, or as the code needs to be executed? I'm just wondering.
You know someone whose parents named him or her Grammar Nazi? If not, you should have said the Grammar Nazi if referring to someone in particular, otherwise any Grammar Nazi.
P.S. I might question the capitalization on Grammar Nazi, but I don't want to pick nits.
Depends on the JVM. Older JVMs would do the translation on load, while newer JVMs will actually interpret byte code until it shows itself to be a "hotspot" for optimization. Then the JVM optimizes the hell out of it. This way the JVM can spend more time optimizing the critical sections for better performance instead of wasting the user's CPU time by compiling and optimizing large chunks of code that will only be run once. That's why Java programs may seem to speed up as you use them.
Javascript + Nintendo DSi = DSiCade