dcsimg
New to Design Patterns
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Phil_Maskell
Posted On:   Monday, December 22, 2003 04:21 AM

Hi, I am completely new to design patterns and J2EE so any help would be useful. I have a basic web page with an embedded flash movie which communicates with a single servlet. The servlet is basically a big if...else statement on the request params from the flash. Each if...else calling an appropriate method, doing some work and returning something to the flash movie. I have been asked by a customer if this the server side servlet would/could be extendable, I want to redesign the whole approach to use a design pattern (is this the right thing to do?), but I don't know really where to start or even if this is the right thing to do. Any help ideas?    More>>

Hi,




I am completely new to design patterns and J2EE so any help would be useful.




I have a basic web page with an embedded flash movie which communicates with a single servlet.




The servlet is basically a big if...else statement on the request params from the flash. Each if...else calling an appropriate method, doing some work and returning something to the flash movie.




I have been asked by a customer if this the server side servlet would/could be extendable, I want to redesign the whole approach to use a design pattern (is this the right thing to do?), but I don't know really where to start or even if this is the right thing to do. Any help ideas?




I have started reading J2EE Design Patterns by William Crawford, Jonathan Kaplan (is this a good book?) and am thinking of something along the MVC lines with all the work done in a JavaBean, the customer will want to be able to add to the if...else in the controller servlet, preferably by some sort of extension without changing my code, how would something like this work? Is there a better pattern for what I'm trying to do?




Any help will be much appreciated.




Thanks in advance.




Phil Maskell

   <<Less

Re: New to Design Patterns

Posted By:   Nick_Maiorano  
Posted On:   Monday, December 22, 2003 08:24 AM

Phil,



The first thing you need to do is to read the classic book: design patterns. This is the book that started the whole design pattern concept. All others, such as the J2EE design patterns, are simply derivatives built upon the classic book.



You will probably end up using some form of the MVC design pattern for your web page but more importantly, you need to address the if...else structure that is really contrary to object oriented designs. Look into the strategy pattern or the command pattern to replace the big block of if...else statements with an abstract class that lets subclasses handle specific logic. Each subclass handles one specific if case. More details in the book...



Note: the MVC pattern is a pattern that gained popularity with the advent of the web-based applications. This book was published in 1995 and unfortunately, the MVC pattern was not included in the design patterns book.

About | Sitemap | Contact