1 Reply Latest reply on Jul 30, 2006 3:09 PM by Ilya Sterin

    quite a design problem..!!!

    Ashutosh Maheshwari Newbie

      Dear Forum,
      I am facing design problem...here it goes...

      I have a class that contains several method having name pattern like "createXXX()".
      All of these methods contains similar logic except data.This class is examined by
      the another class for the"createXXX" methods for futher processing.Suppose name of class containing createXXX method is "abc"..then i have to pass this class to third party class like

      addClass(abc.class);

      Now to avoid almost redundant code and facilites maintenace i want to keep all my data in the xml file and "createXXX" method at the runtime in the abc class using data from xml file.

      How can i make this happen ?

      Thanks in advance ..!!!

        • 1. Re: quite a design problem..!!!
          Ilya Sterin Newbie

          I'm a bit lost as to your response.

          Do you want to figure out the class name at runtime and dynamically pass it? You can use reflection facilities. Not sure what you mean by redundant code, use standard OO techniques and patterns to reduce redundancy in code. Or create some util libraries that do that.

          Or do you mean that you want your classes to not have any create methods and be able to create them at runtime? You can use runtime bytecode injection/enhancement techniquest to do that. Take a look at the cglib libraries, and there are many more.

          Ilya