locked
Applicaton wrapper RRS feed

  • Question

  • User-1271582762 posted

    I have the below requirment:

    Requirement: We have an existing project (application based on .net 3.5) that has been used for couple of years now and we have a requirement to add few more modules to it and use the existing common moduel which are part of the project however, I cannot modify their code as there is an existing release which is going on but I can write a wrapper to encapsulate the current modules/application and write my own module as plug in to it.

    Questions: What design pattern is good as part of my resolution to the problem?

    thanks,
    Raj

     

     

    Tuesday, April 12, 2011 1:38 PM

Answers

  • User1020195037 posted

    Proxy is best when you have a common interface that is implemented by original class that can then be implemented by your proxy. One issue with the proxy pattern is that you redefine all methods and properties as you have only implemented an interface and not inherited a base class. The Adapter Pattern is basically a wrapper pattern where your adapter class implements your original target class.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 13, 2011 8:32 AM

All replies

  • User1020195037 posted

    It sounds like the Decorator Pattern is appropriate in your situation.

    Tuesday, April 12, 2011 3:50 PM
  • User-1271582762 posted

    Hi,

    Thanks for the quick reply; this approach requires adding the interfaces to the existing component; is there a way to avoid this; by inheriting the existing component directly into  my class (in my solution). my class will inherite the existing component and this way I will have access to all the existing methods and I can append new method to it. The whole idea is not to touch their existing code and keep it as it is.

    Please let me know your views.

    thanks,

    Rajshekhar 

    Tuesday, April 12, 2011 4:53 PM
  • User1020195037 posted

    Have you looked into the adapter pattern? IMO, this is usually more for disparate interfaces but might work in your situation.

    Tuesday, April 12, 2011 5:17 PM
  • User-1271582762 posted

    Hi,

    Thanks again. I was going through the Adapter pattern as well as Proxy. And I think, Proxy pattern allow me to make a call to the real time classes/object and can extends the real time class/objects as well by adding the methods in the proxy class. Any thoughts?

    This will help me acheive the below goals:
    1. I needn't touch the exising application and I can write wrapper which extends the existing code base.
    2. Zero merging effort as well as Zero regression testing as I am not changing any of the existing component.


    Thanks,
    Rajshekhar

     

     

    Tuesday, April 12, 2011 6:23 PM
  • User1020195037 posted

    Proxy is best when you have a common interface that is implemented by original class that can then be implemented by your proxy. One issue with the proxy pattern is that you redefine all methods and properties as you have only implemented an interface and not inherited a base class. The Adapter Pattern is basically a wrapper pattern where your adapter class implements your original target class.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 13, 2011 8:32 AM
  • User-1011137159 posted

    I suggest use adapter pattern below very simplate sample example of that..

    http://www.dofactory.com/Patterns/PatternAdapter.aspx

    For your case you need to create separate class library and based on that your requirement you can exetend your class by inherite you existing class so you there is not chagne on your existing functions but you can override or overload or add few for code to extend your features.

    Wednesday, April 13, 2011 8:57 AM