aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Design Pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Design Pattern" Watch "Design Pattern" New topic
Author

Design Pattern

Adeyemi Adegbile
Greenhorn

Joined: Oct 08, 2001
Posts: 8
My question is why don't we have generic interfaces of all the known design and Architectural patterns if they are well know within the software industry like we have the interface for EBJ for example with different implementation in the available Application servers.
I believ these interface should be available in the known OO languages. This will help in the rapid transfer it the benefits of patterns in software development.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Because in most of the cases, Design Patterns don't fix the method signatures.
Additionally, I often find it useful to adapt the patterns to my actual needs. They are just patterns, after all...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Adeyemi Adegbile
Greenhorn

Joined: Oct 08, 2001
Posts: 8
Some of these design patterns have already been captured as interfaces e.g Iterator, Observable; and some as classes Observer, Proxy and Singleton in the Java API for example.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Singleton? Where in the Java API do I find it?
Adeyemi Adegbile
Greenhorn

Joined: Oct 08, 2001
Posts: 8
you can retrieve a Singleton object from the java.util.Collection
method public static Set singleton(Object o)
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Adeyemi Adegbile:
you can retrieve a Singleton object from the java.util.Collection
method public static Set singleton(Object o)

But that is *not* the Singleton Pattern as described by the GoF book. The purpose of the Singleton Pattern is to "ensure a class has only one instance, and provide a global point of access to it." See http://c2.com/cgi/wiki?SingletonPattern
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269
Ilja, tell me, how much do you get each time you put a reference on wiki web?
W.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
An unmeasurable amount of satisfaction, because of having provided a mass of valuable information by just pasting a simple link.
Besides that, nothing.
(But beware: it must be infectious - I have already seen others do that, too )
[ October 09, 2002: Message edited by: Ilja Preuss ]
Adeyemi Adegbile
Greenhorn

Joined: Oct 08, 2001
Posts: 8
Just a an answer to my question in the original post.We have already be able to capture all the Creational Patterns in GOF as generic interface . We have achieved also the static implementation of these interfaces and we will embark on the dynamic implementation of the creation design patterns using JMX API.
We are in the process to releasing the source in due time.
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
No, no. You've missed the whole point of the GOF patterns. It's not that you have a single generic interface for each pattern -- that's not useful. They are templates for you to follow -- your method names will always differ from the names of the methods used in the GOF examples as will the return values and parameters since you will adapt the templates in the patterns to your own design.
That's why no one has done source code interfaces for them before -- because it's not a good idea. In fact, if you look back at the old "Pattern Languages of Programs" books, you'll find a paper by Jiri Soukup in which he did just what you're describing for C++ -- which at least was possible, since C++ has generics, which Java doesn't have. But it wasn't even a good idea for C++...
Had this been what the authors meant they would have included code with the book. They didn't on both counts.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Just wanted to notice that I am totally with Kyle here...
Adeyemi Adegbile
Greenhorn

Joined: Oct 08, 2001
Posts: 8
If what kyle is saying is true, why do we have these Iterator Interface, Proxy Class in java API
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Adeyemi Adegbile:
If what kyle is saying is true, why do we have these Iterator Interface, Proxy Class in java API

The main reason for using an interface is to enable polymorphic method calls. In the case of Iterator, this is reasonable, as it makes sense to make Iterators generally compatible with each other - client code shouldn't care about the source of the Iterator in most cases. For most of the other patterns, such generalization doesn't make much sense; for example, clients of a Singleton most often *will* care which Singleton to use.
The interfaces of many of the patterns, for example the Proxy, even *must* be adapted to the actual use. The java.lang.reflect.Proxy *is not* an implementation of the GOF Proxy, but of the Dynamic Proxy pattern, which uses reflection to handle method calls. It is more flexible, but also more complex than the original Proxy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design Pattern