Java library of patterns

J

joshua.krinsky

I was wondering if anyone knew where I could find a design patterns
library for Java. I've been tasked with creating or finding one and
I've had no luck searching Google.

Thanks
 
C

Chris Smith

I was wondering if anyone knew where I could find a design patterns
library for Java. I've been tasked with creating or finding one and
I've had no luck searching Google.

I have the feeling that you're misinterpreting the purpose of design
patterns. The amount of common code from a design pattern that could be
abstracted into a library is very small; probably less than a page. The
idea behind the design pattern lies in how it organizes your own
functionality when you add to it later. You may as well write that less
than a page of code on your own, rather than complicating deployment by
adding a dependency on a third-party library. If you don't understand
the pattern well enough to implement it, then you're going to run into
problems anyway.

I'd actually go further, and recommend that you keep writing code and
reading about design patterns at arm's length. Don't ever set out to
implement a design pattern. A book on design patterns can give you some
ideas about how to resolve certain kinds of recurring problems, which
you should internalize so that you'll be able to use them organically in
your own designs, rather than producing stilted designs that are driven
by your choice of patterns.
 
L

Lew

Chris said:
I have the feeling that you're misinterpreting the purpose of design
patterns. The amount of common code from a design pattern that could be
abstracted into a library is very small; probably less than a page. The
idea behind the design pattern lies in how it organizes your own
functionality when you add to it later. You may as well write that less
than a page of code on your own, rather than complicating deployment by
adding a dependency on a third-party library. If you don't understand
the pattern well enough to implement it, then you're going to run into
problems anyway.

I'd actually go further, and recommend that you keep writing code and
reading about design patterns at arm's length. Don't ever set out to
implement a design pattern. A book on design patterns can give you some
ideas about how to resolve certain kinds of recurring problems, which
you should internalize so that you'll be able to use them organically in
your own designs, rather than producing stilted designs that are driven
by your choice of patterns.

What Chris said. Beyond that, explain to whomever "tasked" you with this that
the idea is fundamentally incorrect. Design patterns are concepts, not code.

Consider an analogy. In natural languages like English or Tagalog there are
grammatical patterns like "verb" and "sentence". Those patterns manifest
differently in different circumstances; there aren't necessarily preset
"grammatical patterns" in those languages. There are instead an infinitude of
language expressions that manifest those patterns.

Your task is analogous to creating a compendium of grammatical patterns for a
natural language as expressions in that language. You would have to create a
comprehensive set of all possible expressions in that language, clearly not
feasible.

-- Lew
 
T

thejtk

What Chris said. Beyond that, explain to whomever "tasked" you with this that
the idea is fundamentally incorrect. Design patterns are concepts, not code.

Consider an analogy. In natural languages like English or Tagalog there are
grammatical patterns like "verb" and "sentence". Those patterns manifest
differently in different circumstances; there aren't necessarily preset
"grammatical patterns" in those languages. There are instead an infinitude of
language expressions that manifest those patterns.

Your task is analogous to creating a compendium of grammatical patterns for a
natural language as expressions in that language. You would have to create a
comprehensive set of all possible expressions in that language, clearly not
feasible.

-- Lew

What about ACE in C++? It has classes that provide patterns. An
example would be the Reactor pattern [p.179 Pattern Oriented Software
Architecture Vol.2] implementation in ACE [p.39 C++ Network
Programming Vol.2]. This is the sort of thing I was talking about
(although I'm not looking for a Java version of ACE). If it is
possible to have a library of patterns in C++, shouldn't it be
possible in Java?
 
J

joshua.krinsky

What Chris said. Beyond that, explain to whomever "tasked" you with this that
the idea is fundamentally incorrect. Design patterns are concepts, not code.

Consider an analogy. In natural languages like English or Tagalog there are
grammatical patterns like "verb" and "sentence". Those patterns manifest
differently in different circumstances; there aren't necessarily preset
"grammatical patterns" in those languages. There are instead an infinitude of
language expressions that manifest those patterns.

Your task is analogous to creating a compendium of grammatical patterns for a
natural language as expressions in that language. You would have to create a
comprehensive set of all possible expressions in that language, clearly not
feasible.

-- Lew

What about ACE in C++? It has classes that provide patterns. An
example would be the Reactor pattern [p.179 Pattern Oriented Software
Architecture Vol.2] implementation in ACE [p.39 C++ Network
Programming Vol.2]. This is the sort of thing I was talking about
(although I'm not looking for a Java version of ACE). If it is
possible to have a library of patterns in C++, shouldn't it be
possible in Java?
 
M

Mark Jeffcoat

What about ACE in C++? It has classes that provide patterns. An
example would be the Reactor pattern [p.179 Pattern Oriented Software
Architecture Vol.2] implementation in ACE [p.39 C++ Network
Programming Vol.2]. This is the sort of thing I was talking about
(although I'm not looking for a Java version of ACE). If it is
possible to have a library of patterns in C++, shouldn't it be
possible in Java?

What about ACE? It "implements many core patterns for
concurrent communication software." Good for it. So does
java.util.concurrent.*. I'll be happy to declare it a
pattern library.

Spring provides much support for MVC, Inversion of Control,
Data Mapper, and many more. Very much a pattern library.

log4j implements Neil Harrison's Diagnostic Logger pattern,
and is (deservedly) nearly ubiquitous in the the server
programming world.

java.util.Iterator is a perfectly decent implementation
of the Iterator pattern. Also fairly common in Java
programs.


Maybe you could ask for something more specific?



(If I were tasked with finding a "pattern library in
Java" by someone who obviously didn't know what he was
talking about, I'd be tempted to show up at the next
meeting with a copy of Spring and go home early.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,113
Latest member
Vinay KumarNevatia
Top