Skip to main content

Strategy, Template, and Bridge

Posted by daniel on October 29, 2004 at 7:32 AM PDT

Uncle Bob plays with my favorite patterns

I know you're not supposed to have a favorite design pattern or else you're likely to go in search of nails to pound with it. That being said, my favorite of the Gang of Four patterns is the Template Method. It is certainly my favorite in an introductory class because students see the power of polymorphism and the point of inheritance.

In the latest installment of Robert C. Martin's "Principles, Patterns, and Practices" column, Uncle Bob looks at The Strategy, Template Method, and Bridge Patterns. Students often have difficulty choosing which pattern to apply when more than one would solve the problem. This article shows problems that could be solved with either Template or Strategy and shows how you can see that choosing the less appropriate one would unnecessarilly complicate your design.


In Also
in Java Today
, threading is much improved in J2SE 5.0, with the old wait() and notify() augmented with a whole new package of tools for coordinating threads. In Advanced Synchronization in Java Threads, Part 1, an excerpt from Java Threads, 3rd Edition, Scott Oaks and Henry Wong introduce the Semaphore, Barrier, Countdown Latch, Exchanger, and ReaderWriterLock classes introduced by the new java.util.concurrent package.

Here's a light piece for a Friday - the Blog Glossary. No Tiger, no look at the latest APIs, just some definitions from the world of blogging like Anti-idiotarian, Blogorrhea, Blogstipation, and Hitnosis.


In Projects and
Communities
, the Java Device Open System (JDOS) project, part of the JDDAC targets a 12cm x 12cm miniature motherboard and Gentoo Linux to fit a lot of J2SE 5.0 in a very small space.

Build your GUI with FastSwing the Java User Groups project aims to develop a framework to provide reusable frames and fields for developing new desktop applications.


What about a javac -source 1.6 -target 1.5 [or 1.4 or 1.3] in Mustang? In today's Forums Jodeleit writes "It would be cool if Mustang / 1.6 / 6.0 would use @Since(major=1,minor=6,micro=0) for classes / packages / methods instead of the "out of fashion" javaDoc tag. Combined with package annotations for the jar [@jar("rt.jar")] errors could be generated like: Error: target is 1.5 - usage of "java.lang.String.coolMustangFeature()" is not allowed.."

MGrev complains that "Conditionally adding items to a JComboBox is unnecessarily verbose. Today one need to iterate over the items to do this or cast the model to a DefaultComboBoxModel which isn't intuitional unless you read the API source code.I suggest adding some or all of these convenience methods[..] addUniqeItem(Object item), setSelectItem(Object item, addIfNotExist), containsItem(Object item)."

MThorton adds to the primitives and generics discussion saying "It was certainly considered. I made a proposal that would allow primitives as type arguments during the first public review. The biggest problem wasn't technical, but rather the political problem of reopening the debate about whether primitives should exist at all (i.e. continue to have special status relative to regular objects). "


In today's java.net
News Headlines
:

Registered users can submit news items for the href="http://today.java.net/today/news/">java.net News Page
using our news
submission form
. All submissions go through an editorial
review before being posted to the site. You can also subscribe to
the href="http://today.java.net/pub/q/news_rss?x-ver=1.0">java.net
News RSS feed.


Current and upcoming
Java Events
:

Registered users can submit event listings for the href="http://www.java.net/events">java.net Events Page using our href="http://today.java.net/cs/user/create/e"> events submission
form. All submissions go through an editorial review before being
posted to the site.


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 java.net it will be
archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.

Uncle Bob plays with my favorite patterns