1 Reply Latest reply on Mar 31, 2014 3:34 PM by rp0428

    modify internal object structure using any design pattern


      I have a design scenario here which is quite interesting and complex. I have a Java class structure as follows,

      class A


           class B;

           innerClass B


                List<class C> listofC;

                innerClass C


                     String attribute1;

                     String attribute2; // Their getter setters




      So I have this as an API. Now my challenge is that I need to add one more property to inner class C.  i.e attribute3 in innerClass C. I need to do this without disturbing the code in class A by extending these classes or writing a new wrapper, so I can use class C with new properties .

      I hope this should be achievable through any design pattern either at runtime or design time. Please help me through ?



        • 1. Re: modify internal object structure using any design pattern

          Sorry - that isn't clear to me. You show 'Class B' indented under A but then you also show an INNER 'Class B'.


          Is B an inner class of A? Is C an inner class of B?


          What does 'without disturbing the code in Class A' mean? If you modify an inner clause then, by definition, you are modifying the outer class.


          What does 'so I can use class C with new properties' mean? Use it where? As said above if C is an inner class then it is PART OF its containing class. Any change to C automatically changes A since C is a part of A.


          What PROBLEM are you trying to solve. You have tried to tell us the solution you want to use but we need to know the problem.