in reply to Re^4: Re-blessing || Re-constructing objects
in thread Re-blessing || Re-constructing objects
Then I'd ask why you wrote this code as OO, since you aren't getting a major benefit of OO: abstraction.
There are many common approaches for doing the kind of thing you describe that don't require breaking encapsulation. They're so common that they have design pattern names, like "decorator" (wrap one object with another), or "strategy" (delegate the handling of certain methods to different objects determined at runtime). You could also just use the original object's public API to get the data to populate the new objects (a "factory" pattern).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Re-blessing || Re-constructing objects
by blogical (Pilgrim) on Apr 18, 2006 at 04:30 UTC | |
|
Re^6: Re-blessing || Re-constructing objects
by demerphq (Chancellor) on Apr 18, 2006 at 10:26 UTC | |
by perrin (Chancellor) on Apr 18, 2006 at 11:07 UTC | |
by demerphq (Chancellor) on Apr 18, 2006 at 11:20 UTC | |
by perrin (Chancellor) on Apr 18, 2006 at 11:29 UTC | |
by demerphq (Chancellor) on Apr 18, 2006 at 18:45 UTC | |
| |
|
Re^6: Re-blessing || Re-constructing objects
by adrianh (Chancellor) on Apr 18, 2006 at 13:58 UTC | |
by perrin (Chancellor) on Apr 18, 2006 at 14:26 UTC | |
by adrianh (Chancellor) on Apr 18, 2006 at 14:40 UTC |