views:

136

answers:

2

1. I need to build a "Web Service Server (Simulator)" which generates the xml files and also sends async calls to the client for notification. At this point, I am writing a code to generate dummy XML files which will be used for testing (FileGeneratorClass-- builder)?

2. Also, can I implement this in a way that I do not have to write a complete code from scratch to simulate another web service server and another file format ? - what pattern can I leverage there ?

3. The objects/classes are generated from a Schema file (for xml File) and WSDLs ( for web service ), how can I make my code immune to changes to these files (newer versions) ? - which design pattern ??

(Please let me know if information I provided is too much or too less, also if you need me to edit)

Thank you very much.

Disclaimer: I am a complete newbie and using patterns for this small project might be overkill yet I want to do it so that I learn/understand it. Which, I think, will give me confidence and clarity when I need to do that in a more complex project.

+9  A: 

Patterns don't do anything. You are asking if you should use prepositional phrases when you are planning to write a mystery novel. You don't start a design saying what patterns do I need. Patterns emerge from the design process. You say my program will need x and y, that's similar to the such-and-such pattern, I should see if that pattern fits. If it does, use it. If it doesn't fit, don't force it to fit.

You are treating patterns like classes. Don't do that. That's not their purpose. They are not building blocks. They are not checklist entries. They are exactly what the mundane meaning of patterns implies. They are things you see repeated over and over. Many times you sense their necessity ahead of time and so you include them in the design. But they are not a starting point.

jmucchiello
you are suggesting that I should write the code and slowly it will dawn on me?? in other words "is experience absolutely necessary to understand what to use where?"
Gollum
I think the right way to think about it is during your initial coding you start with nothing and build on it. Once you start to see code that is duplicated or has too many couplings or needs to be reusable somewhere else, etc, etc... then you begin applying patterns where necessary to solve some of those problems. Patterns should be applied during refactoring where needed.
Charlie Brown
No. I'm saying you should design interfaces and class hierarchies and whatever else is supported by your design method of choice. And as you drill down into the design, the things we call design patterns will emerge. Then instead of explaining why you have this function and that function you just it uses the specific pattern and move on.
jmucchiello
@Charlie - Patterns can exist before the code is written but only if you actually design (both high and low level) before coding. The distinction is that patterns are not cookie cutters. You don't say you want to use Pattern X. You say my problem can be solved with Pattern X so I will use it.
jmucchiello
I recommend *Refactoring to Patterns* by Joshua Kerievsky (http://www.industriallogic.com/xp/refactoring/). The first chapter describes how the author initially approached patterns as so many of us do at first: use as many as you can, as often as you can. This is over-engineering. The book goes on to describe a number of refactorings used to move towards, or away from, a pattern.
Jon Reid
Thanks you guys !
Gollum
@Jon, the book is really good, thanks.
Gollum
@KaluSingh, glad to hear it, and thanks for letting me know. :)
Jon Reid
+2  A: 

Sometimes there just isn't any other way than doing the research. If you wish to learn design patterns then start studying design patterns. Learn a little each day, and as you do your normal coding you will begin to see uses for what you've learned. Personally, I like the way Wikipedia has tackled the topic (as opposed to some of the books). Read the overview, and then dive into the ones that you foresee as having some relevance to what you are trying to do.

Also, you may be interested in Enterprise Integration Patterns, as opposed to design patterns, which apply more to web services than to algorithms.

harschware
Yes, Thank you!
Gollum