Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Java network programming books: A comparative review

Laurence sifts through another batch of Java books, trying to separate the nuggets from fool's gold

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Page 3 of 6

Java Network Programming (Manning)

This Java Network Programming is very different from its identically named competitor. This book devotes a lot of chapters to cryptographic theory and implementation, and the bulk of the material bypasses much of the microscopic detail of Java's networking classes to build interesting and well-designed networking application frameworks on top of them. In addition, the book spends a surprisingly large number of chapters discussing Java's I/O stream classes (as a prerequisite for designing the frameworks later on). The debatably large amount of pages used to study the stream classes is more than offset by the very high quality of Part III, "Real Networking Applications," where stream classes form the architectural heart of a framework for client/server and virtual peer-to-peer applications.

Java Network Programmingming



Following Chapter 1, "Introduction to Networking," the authors clearly show that they consider secure communications a very important topic: Chapters 2 and 3 are called "Introduction to Cryptography" and "The Java Security Model," respectively. And it doesn't end there. Five more chapters (for a total of 7 out of 29) are devoted to increasingly advanced cryptography, encryption protocols, and algorithms. Personally, I disagree that secure communications need to be covered in such detail. Although an important topic in its own right, it should be covered in just one or two chapters in a book with "Network Programming" as its title (admittedly the front cover does state "Covers Cryptographic techniques for secure Internet applications," so readers are forewarned).

The book's main strength is its very high-level approach to designing networking applications. The following quotation is just one small example of which wavelength these authors are on: "...the MessageCopier will be the only thread that can experience an IOException as a result of a failure in the underlying communications channel. We can thus write an application that does not need to be able to handle communications failures occurring wherever a read() call occurs. Instead, we can write most of the code to only handle errors of incorrect message formats and other programmer errors...." This is software engineering in action, not Java hacking, and is why I really liked this book. Many authors can show you how to hack a bit of code, but few can show you how to design clean and flexible systems.

Another aspect of the book that impressed me was the quality and consistency of the diagrams. To explain the architecture of their stream-based networking applications, the authors do not use a conventional notation (like a Booch object diagram or such), but rather their own, infinitely clearer (!), iconography. Some of the later diagrams start to look so much like electronic circuit diagrams that they are almost small pieces of art. I loved them.

The book is not without its share of errors, though. One of the more serious errors is found in Chapter 27, "Object Serialization and Persistence." Twice the authors state that ObjectOutputStream inherits from DataOutputStream. These statements are incorrect since ObjectOutputStream inherits from OutputStream and implements the ObjectOutput interface. ObjectOutput then implements the DataOutput interface. The problem with this error (which at first doesn't look very important) is that the authors further state that ObjectOutputStream.writeInt() is inherited from DataOutputStream.writeInt(), implying that ObjectOutputStream streams are somehow compatible with DataOutputStream streams, which is again false. The streams produced by ObjectOutputStream and DataOutputStream are totally incompatible, which is why JavaSoft couldn't subclass DataOutputStream to produce ObjectOutputStream in the first place!

On the code front, as with the O'Reilly book, the authors use extremely poor program identifiers, including i1, o0, mI, qO (these would undoubtedly be qualified as "horrors" in Steve McConnell's Code Complete, the bible of good coding practice (published by Microsoft Press)). In this case, the choice of identifiers seriously degrades the readability of the programs, even more so than in the case of the O'Reilly book. Surprisingly, in view of the otherwise excellent use of diagrams, the authors also forgot or did not deem it necessary to include class hierarchy diagrams for either Java's networking packages or their own. In the case of Java's networking packages, this omission becomes a problem because the authors also do not provide complete class listings. This means that the reader is left in the dark as to the full extent of the classes and methods available to the programmer.

Advanced Java Networking

If you read September's game programming books review, you'll remember that I am always suspicious of books containing the word "Advanced" in their title. Regrettably, Advanced Java Networking arrived this month to confirm my suspicions. The first chapter called "Basic Java" talks about the absolute basics to such an extent that you just know the remainder of the book will not deliver on the promise of its title. This is a shame because the table of contents sounds exciting due to the spectrum of subjects covered: Sockets, IDL, RMI, JDBC, the Java Web Server, and JMAPI, among others. Unfortunately, all of this material is presented in a very disappointing manner. The explanations are often sloppy (or just plain wrong), the author's writing style is sloppy, the program listings are sloppy, and the diagrams are...you guessed it, sloppy.

Advanced Java Networking



Let's begin with the sloppy explanations. Here are a few entries from the glossary:

  • "Encapsulation: Object-oriented programming, practice of."
  • "Language Mapping: The means necessary to take one language and convert its syntax and semantics to another language."
  • "Serialization: The act of transforming a Java object into a string representation."
  • "Thread: A series of executable steps that are executed along with other steps."
  • "UDP: Unreliable Datagram Protocol."


Any Java programmer with some experience will instantly recognize the flaws in the above "definitions." Within the text, the author further mixes up the following concept pairs: byte and character, class and object, and subclassing and implementing an interface.

As for some examples of the poor writing style, how about this: "Once we detect some semblance of information coming across the socket, we must pop a thread automatically and let the thread get and process the information." Need another example? Try this: "UDP is a 'spit in the wind' protocol. One day, you wake up, spit into the wind, and hope it will land somewhere." Or this: "Datagrams are sort of like that old 'I love Lucy' episode in which Lucy and Ethel go to work in a candy factory. As they stand in front of a conveyor belt, little candies begin to flow out. Lucy and Ethel are able to wrap and package the candies as they come out. Soon, their boss speeds up the belt and the candies begin to flow out really fast and Lucy and Ethel are unable to keep up." .... Did I say the title contained "Advanced?" Add to this a chapter on JavaBeans and one on JavaOS and JavaSoft's Java Microprocessors, which have absolutely no place in a book on Java Network Programming.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (1)
Login
Forgot your account info?

Java Networking book.By Anonymous on October 15, 2009, 4:26 pmSuggust me books related to java networking with focus on communication using TCP, UDP and other protocols and techniques like Peer to Peer that can be used for...

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources
  • JavaSoft's Java Tutorial is always a good source for officially sanctioned code examples, although it usually takes a while for the tutorial to reflect the latest APIs. The tutorial includes sections on the networking APIs. http://www.javasoft.com/doc/tutorial.html
  • This Web page is the home of a mailing list devoted to Java network programming discussions. It also contains a link to the complete archive for this list (unfortunately as a single 3Mb text file!). http://www.cdt.luth.se/~peppar/java/java-networking-list/
  • A Q&A page from San Diego State University's CS596 Client-Server Programming course (rather dated, from early 1996). http://saturn.sdsu.edu:8080/~whitney/courses/spring96/cs596/notes/java/javaNetworkQA.html