Skip to main content

Between Us

Posted by editor on November 28, 2006 at 6:52 AM PST

When constructors need to be private

Sometimes when we get a not-so-stupid question, we need to expand the question as originally submitted, to give readers a little to chew on before they reach the discussion section. And that can be a little tricky when we already know the answer. It does require mentally placing one's self in the mind of someone who hasn't been programming in Java for a long time.

In other words, if I can forget the many times I've banged out a singleton pattern, I can take myself back to a place where the idea of a private constructor didn't make sense. To the new programmer, this can be a valid conundrum: if you would need to have an instance of some class to call a private method on that class, and would need to call a private constructor to create such an instance, it seems like a logical impossibility.

Many of you see the hole in this reasoning (I'll bet you've written a few singleton patterns in your time, yes?), because within just an hour of posting today's Feature Article, there were already four substantial talkbacks. And I'll bet there are more uses to be discussed other than just the singleton. So please have a look at
(Not So) Stupid Questions 15: How Can a Constructor Be Private? and see if you can add something to the discussion.

In Java Today,
the ossj-tck-foundation project has
graduated fom the incubator to a Java Enterprise project. The goal of the OSSJ TCK Foundation project is to ease creation of OSS/J TCKs by ensuring that the TCK builder can focus on building test cases and not having to worry about the 'plumbing' that is needed to bridge the 3 integration profiles (EJB, XML/JMS, Webservice) that are defined for all OSS/J APIs.

To celebrate the NetBeans 5.5 launch, NetBeans has put together the second edition of NetBeans Magazine, focusing on enterprise development. This edition of NetBeans Magazine covers a wide range of new features in NetBeans 5.5 and its main extensions, while also delving into core Java technologies. You can view this issue as a whole or as individual articles.

Java Puzzlers author Neal Gafter is back again with A Thread Pool Puzzler: "When I started using java.util.concurrent I was already somewhat comfortable with [its] concepts. But when I used it more intensely for production work in the Google Calendar server, I ran into a couple of 'gotcha' situations. I'd like to tell you about one in particular, in part because it might help you avoid the problem yourself, and in part because I believe this issue exposes some missing functionality in the concurrency framework."