Chapter 2 Substitutes for Missing C Constructs
By Joshua Bloch
June 16, 2000
Introduction | Substitutes for Missing C Constructs
Here is a preview from the book, "Effective Java Programming" by Joshua Bloch. This book is in the series, "Java from the Source," to be published by Addison-Wesley late 2000 or early 2001. The preview is Chapter 2, "Substitutes for Missing C Constructs."
Note from the AuthorThis sample chapter discusses C constructs that have been omitted from the Java programming language, and presents the best alternatives for these missing constructs. Of particular interest is Item 3, which discusses the
typesafe enum pattern, a replacement for C's
enum
construct. This pattern is not widely known, and it has several advantages over alternatives currently in common use.
The book, tentatively titled Effective Java Programming, is an attempt to do for Java what Scott Meyers's "Effective C++" (Addison-Wesley, 1992) did for C++. It distills into 50 or so short essays (approximately four pages in length, each) the things that experienced Java programmers generally do or generally avoid. The essays have titles like "Avoid Finalizers" or "Prefer Delegation over Inheritance." The book explains why each practice is desirable or undesirable, and presents alternatives to practices deemed undesirable. Each essay is freestanding, and the essays are loosely grouped into Chapters. Nearly every essay contains one or more code examples.
The book largely (though not religiously) restricts itself to the "core" of the Java platform: the language and the
java.lang
and
java.util
packages. As a consequence, nearly all of the essays should be relevant to nearly all Java programmers.
The target audience for the book is intermediate Java programmers; it assumes a working knowledge of the language and core libraries. Although the book is aimed primarily at intermediate programmers, advanced programmers will find food for thought in some essays, especially advanced programmers with ingrained habits acquired from years of programming in other languages such as C and C++. The book is not about Design Patterns and does not assume any knowledge of the subject, but it takes a pattern-centered approach.
Substitutes for Missing C Constructs
Ordering Information
Barnes & Noble
Joshua Bloch is a Senior Staff Engineer at Sun Microsystems, where he is an architect in the Core Java Platform Group. He designed and implemented the Collections Framework and java.math, and contributed to other parts of the Java platform. He is currently leading efforts to add assertions and preferences to the platform. Previously, he was a Senior Systems Designer at Transarc Corporation, where he designed and implemented many parts of the Encina distributed transaction processing system. He holds a Ph.D. from Carnegie-Mellon University and a B.S. from Columbia.