Arnav Mitra

Greenhorn
+ Follow
since Oct 12, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Arnav Mitra

Oh it was not at all a dumb question. "No questions are dumb" that's what K&B's Head First says right?


Cheers,

Arnav.
Can you please tell more about what you are trying to achieve? The purpose of Factory, Decorator and Strategy are different. The use of interfaces alone does not make a Factory, Decorator or Strategy and they belong to different genre.

Factory: Creates an instance of several families of classes. [A Creational Pattern]

Decorator: Add responsibilities to objects dynamically [Structural Pattern]

Strategy: Encapsulates an algorithm inside a class. [Behavioral Pattern]

Check this online resource out, its quite simple and friendly: http://sourcemaking.com/design_patterns

Characteristics of Decorator:

The Decorator Pattern is used to extend the functionality of an object dynamically without having to change the original class source or using inheritance. This is accomplished by creating an object wrapper referred to as a Decorator around the actual object. That ways decorator is an alternative to using inheritance.

  • The Decorator object is designed to have the same interface as the

  • underlying object. This allows a client object to interact with the Decorator
    object in exactly the same manner as it would with the underlying
    actual object.
  • The Decorator object contains a reference to the actual object.
  • The Decorator object receives all requests (calls) from a client. It in turn forwards these calls to the underlying object
  • The Decorator object adds some additional functionality before or after

  • forwarding requests to the underlying object. This ensures that the additional functionality can be added to a given object externally at runtime without modifying its structure.

    Strategy Pattern

    The Strategy pattern is useful when there is a set of related algorithms and a client object needs to be able to dynamically pick and choose an algorithm from this set that suits its current need.

    Well...!!! I guess this short introduction will probably help you a little. From your code it seems you have something related to dynamic behavior. Just be sure what you are trying to achieve and often Design Patterns are used in conjunction to each other.


    [ May 01, 2008: Message edited by: Arnav Mitra ]
    Here is a small application that helps you to post your skills into a database also it offers an option to cut-paste a part of your resume.

    It uses a simple HttpServlet, a DAO and HTML. Hope it gives you some insight to the Servlet API. I'll share the code here.

    The DAO





    web.xml
    17 years ago
    I am working on a Struts Based CRM project right now and would be releasing it for people who want to learn Struts with real world examples and real use cases.
    17 years ago

    Originally posted by Angela D'souza:
    Hi,
    I was working in J2EE and Servlet for four years in 2004. After that, due to my son medical condition i resigned job. Then after i didn't any work on java for 3 yrs now. I want to do practice so i can apply again in market. Can anyone let me know good user friendly tutorials on Java (setup, coding etc for J2EE) through which i can learn fast.
    Also which version is latest in J2EE, Tomcat, Webshere, Weblogic in market?
    Thank You,
    Angela

    [ February 21, 2008: Message edited by: Angela D'souza ]



    There are some nice tutorials at coreservlets.com specially Marty Hall's.
    If feel Marty Hall is a great author, besides him you can go for SCWCD by Hanumant deshmukh.
    [ February 27, 2008: Message edited by: David O'Meara ]
    17 years ago