Skip to main content

One More Time

Posted by editor on September 6, 2005 at 7:55 AM PDT

Returning to "Head First" country

One of our most popular, and maybe a little controversial, Featured Articles is Breaking the Last Dependency by Head First Design Patterns co-authors Elisabeth Freeman and Eric Freeman. Our database shows us that a lot of people have read this article since its original appearance, and the great number of talkbacks show that many have had different reactions to it.

One criticism you'll see in the comments is that the code isn't the most efficient, but that's to be expected of code that's illustrating a new technique -- things will be different in the run-once example versus the up-for-months server. You have to start somewhere.

What's maybe more interesting is how their approach changes the nature of programming. A quick recap: the idea of the article is that the Factory Pattern described in the book still depends on instantiating and returning concrete classes... a behavior not entirely true to the goal of programming to interfaces. The authors say: "As Head First Design Patterns was about to go to press, Erich Gamma sent us a note suggesting that in the factory pattern chapter we should break the last dependency and show how to write code that does away with concrete classes completely." The technique of doing so uses a property file to describe which classes should be provided by the factory, and using reflection to instatiate them.

Some of the comments reflect the idea that this effectively makes the properties files part of your "code", and a part that doesn't benefit from Java compile-time checking. As reader napier notes:

Some comments mention that this technique will break compile-time checks, but it seems to me that's inevitable. If you break the last dependency, then you have isolated one set of classes from another (through properties files, reflection, etc.), so that the classes don't need to know about each other. You'll lose the compile time checks but if want the code to function independently you'll have to give up something. What you gain is code that is actually modular, which in certain situations can be very valuable.

Take a look at this piece if you haven't before, and even if you have, have your opinions of this approach changed? With the increasing use of annotations, dependency injections, and other styles of meta-programming, do the objections still stand, or are they increasingly typical of modern Java programming practices? And is completely eliminating the dependency on concrete classes worth it?

John O'Conner is bothered by a gotcha of Building Java SE 6.0 (Mustang) on Windows
In today's Weblogs:
"Mustang requires the Microsoft Visual C++ compiler for builds. Although Sun is encouraging users to download, build, and improve Mustang, does this compiler requirement effectively limit participants? Do the majority of contributors come from Linux backgrounds, where dev tools are open and free?"

XML, Readers, and Streams: A Cautionary Tale, Ben Galbraith laments:
"If a system's glitches can be compared to fish, I want to tell you about my white whale. Learn from me. Spare yourself the pain of wrestling with this one yourself. Make me feel my time was well spent.

Romain Guy highlights desktop Java in Zoom Pictures with SwingLabs FX:
"SwingLabs FX module provides new Swing components to create interesting effects. See how to use the new ZoomableImagePanel together with other effects."

In Also in
Java Today
the article Web Services: REST in Peace? presents the case that the REST and orthodox positions have not only converged, but that the so-called orthodoxy has actually surpassed the REST architectural principles by decoupling the Web from Web Services and reducing the REST approach to a subset of the new Web Services architecture.
"While the Web Services community has much to thank the REST community for in terms the insight they brought to the discussion, the fact is that Web Services -- at least in more enlightened quarters -- are now on the right track."

JDBC 4 is the forthcoming release of the Java Database Connectivity API. Currently in Early Draft Review in the JCP (JSR 221), JDBC 4 is a major new release with a strong focus on ease-of-use and programmer productivity. The new JDBC version also introduces support for SQL 2003 data types, including SQL's native XML type. Frank Sommers' Upcoming Features in JDBC 4 has a preview of what's next for JDBC programmers.

In Projects and
the latest JavaTools Community Newsletter announces the graduation of the Hibernate Query Editor (HQE) project from the community incubator. HQE simplifies the creation of HQL/SQL queries for Hibernate by adding syntax coloring and other conveniences.

The early draft review for JSR 246: Device Management API closes on Wednesday (Sept. 7). This JSR is an optional package for the J2ME CLDC configuration that provides a generic interface to the device management implementation specific to the device.

More discussions about feature creep appear un today's Forums.
Re: #region like what is in C#, kcpeppe writes:
"Are you suggesting that we implement every idea that comes through this forum? What would the language do if we did that. I don't think the idea is to halt langauge evoluation. However, we do need to be selective about what is accepted and what isn't. There is a fine line between language features that are disruptive and those that are helpful. Sometimes innocent language features can destabilize the usability of the language. I think that is only one criteria in which changes to the language needs to be evaluated before embarking on the change because once released into the wild, there is no chance of pulling it back."

jam1000b wonders if there's an
Accounting system framework available?
"I am scoping a project to be developed in Java that needs a basic accounting sub-system ... AR, AP, GL ... the basics only but for a large volume of transactions. Does anyone know of a customizable Accounting framework built in Java that implements the accounting business rules and provides an API for building the user interface? Any advice will be highly appreciated."

In today's
News Headlines

Registered users can submit news items for the href=""> News Page using our
news submission
. All submissions go through an editorial review before being
posted to the site. You can also subscribe to the href=""> News RSS

Current and upcoming Java

Registered users can submit event listings for the href=""> Events Page using our href=""> events submission form.
All submissions go through an editorial review before being posted to the

Archives and Subscriptions: This blog is delivered weekdays as
the Java
Today RSS feed
. Also, once this page is no longer featured as the
front page of it will be
archived along with other past issues in the href=""> Archive.

Returning to "Head First" country