-1

I am new to OOP ,I had data storage class which need to store temporary data which need for future calculation in a application ,i need to assign different values into this class and return class objects more than one,according to my knowledge there is OOP pattern which i can used for this kind of problem which increase re- usability if some one have have expert in this area please help me to find best pattern for my problem.

Thanks !

DilW
  • 27
  • 2
  • 8

1 Answers1

0

One possible solution to this is the usage of Decorator design pattern. You can implement participants like this example:

  • Component (LibraryItem) defines the interface for objects that can have responsibilities added to them dynamically.

  • ConcreteComponent (Book, Video) defines an object to which additional responsibilities can be attached.

  • Decorator (Decorator) maintains a reference to a Component object and defines an interface that conforms to Component's interface.

  • ConcreteDecorator (Borrowable) adds responsibilities to the component.

ekostadinov
  • 6,880
  • 3
  • 29
  • 47
  • I am sorry actually i don't need to add items into a class at dynamically at run time,i need to create more instance in a same class at run time – DilW Oct 10 '14 at 09:03
  • If you considering deep clones, take look at this [stack question](http://stackoverflow.com/questions/78536/deep-cloning-objects) – ekostadinov Oct 10 '14 at 09:09