Hi Pattern Fans, As most of you probably know, I'm the author of the book you might win this week -- the Pattern Almanac 2000 -- that summarizes the current pattern literature. One of the things I tried to do was to include reports of pattern use in the form of published papers to allow developers a place to go to see how a particular pattern solved a real problem. I know that most people don't have time to write papers so here's your chance :-)! What is your favorite pattern and, briefly, why is it your favorite, that is, can you tell a very short story about how the pattern helped you solve a problem? I think we would all like to hear these stories! Thanks! Linda
Hi Linda, It is exciting to see your book as a giveaway this week. Among all the patterns one of my favorite is factory pattern. It was helpful to me in solving the assignment for Java developer certification. To be precise, I used the pattern to connect my client to the database in local or network mode. In this case, the client never knew what mode it is connected to the database in, and hence was very flexible. The factory enabled me to generate objects depending upon the parameter passed to it.
Hi! I was trying to use in my assignments quite simple , but very efficient Decorator pattern. Advantage of this pattern that additional capabilities could be added dinamically and nature of changes for basic object could vary quite in a big range. [This message has been edited by Vladimir Kositsky (edited February 01, 2001).]
One pattern I tend to use quite a bit is "Template Method". I have been using this pattern long before I knew that it was one - it just seemed natural to me to implement certain applicatios that way. :-) I guess this is probably my favorite pattern, although there are not too many patterns that I have had a chance to use so far. Singleton and Factory would probably be the next patterns on my list of favorites. -Mirko
I can't live without Singleton, Factory and Adapter I don't remember a single project where I didn't need to provide a single-point access to resources (Singleton). I often build parameterized interfaces (Factory + Singleton) and Adapter is a must when interfacing with pre-existing services. Kathy
Joined: Jan 21, 2001
These are great stories! It's interesting to see what patterns other developers are using. Then, later, if we have a question about a particular pattern, we just might go back to that story and it will help us. More stories!!
All this focus on Singleton worries me sometimes. I've seen ill-judged Singletons do untold damage to designs. Building a Singleton into a design is equivalent to declaring that there can never be more than one of whatever it is, but many people use it as if it is equivalent to "there is only one of these at the moment". Let's take an example: You are modelling a process-flow system on the structure of a company. The company has several offices, several employees, several products etc. The company has only one HR department, only one CEO, only one company name and so on. I have seen systems where over-eager patterns users have applied Singleton to anything which looks like there is only one of it. This system then breaks horribly if it needs more than one of them. Most people agree that global variables are bad, and assume smugly that Java is safe because it doesn't have them. Singletons are often just global variables, with all the problems of the same. Please think twice or three times before using Singleton. Use Factory or Abstract Factory, use a configuration file, whatever. But don't nail your designs' feet to the floor by building in Singletons if you don't really need to.
I use Factory constantly. that results in a very loosely coupled system. I recently did a benefits enrollment app that used JSP - by designing an interface that the JSP expected, I could create different types of benefit classes on the fly without the JSP having to have intimate knowlegde of the concrete classes. I have read both Mark Grand books - the first is very good, the second is more of a "best practices" rather than a patterns book.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR> fantastic, a towel? <HR></BLOCKQUOTE>
Hi all I agree that Singleton can be abused, but I have found it useful for some things: A single pool of resources, a single Logger, etc... I also find myself using Facade, Decorator, and Observer pretty often. I use various forms of Factory, but I confess that I rarely use Abstract Factory in its full form. My favorite pattern is Composite. I just like the way it lets me combine lots of small simple things into one cool thing. CT ------------------ C.T. Arrington Author of Enterprise Java with UML
Hi all When it comes to enterprise applications in a clustered environment, Singleton pattern has little/no role to play. Facade/delegator patterns are my obvious choice in the business tier (simple pattern, offering great performance with single network round trip). In the web tier mediator-view pattern is the simplest way to implement session and security management (gateway model) and also provide logical mappings to your view. -Kiran.
[This message has been edited by Kiran pudhota (edited February 28, 2001).]
Joined: Dec 01, 2000
Lightweight data-centric proxies live on the client, heavy-weight persistent objects, mining that data, live on the server. Everybody is happy!
I would just like to mention a couple of the lesser-known patterns I have encountered and found interesting in the past: Bob Martin's (http://www.objectmentor.com) Acyclic Visitor pattern Allen Holub's (http://www.holub.com) proposed Visual-Proxy pattern presented in a series of articles in JavaWorld. I don't know if I have a particular favorite; it all depends on what type of problem you encounter in your work the most often. I have found the Command, Observer, Facade, Decorator, Bridge, Singleton and Abstract Factory patterns useful. Junilu P.S. to bartenders/sheriffs: how do I change my user name to proper name case? I want to continue to use my current name and tried re-registering using proper name case but got a "duplicate" error. Thanks.
[This message has been edited by JUNILU LACAR (edited March 01, 2001).] [This message has been edited by JUNILU LACAR (edited March 01, 2001).]