in reply to Re^3: Re-blessing || Re-constructing objects
in thread Re-blessing || Re-constructing objects

no, please, don't misunderstand me, I am not advocating into reblessing objects wildly from one class into another. I am just saying that doing it in a controlled manner is an useful mechanism and it can be used without breaking encapsulation or any other OOP property.

Those controlled manners are at least two:

Replies are listed 'Best First'.
Re^5: Re-blessing || Re-constructing objects
by demerphq (Chancellor) on Apr 18, 2006 at 18:53 UTC

    I am just saying that doing it in a controlled manner is an useful mechanism and it can be used without breaking encapsulation or any other OOP property.

    Well said. Just because something is dangerous doesn't mean it can't be used in a positive way.

    ---
    $world=~s/war/peace/g

Re^5: Re-blessing || Re-constructing objects
by perrin (Chancellor) on Apr 18, 2006 at 18:53 UTC
    It can't be done without breaking encapsulation. All of your examples require a class to know all about the internals of some other class. You may decide that's okay in your case, but it still loses the abstraction.

      Just out of curiousity do you consider "friend" classes to violate encapsulation?

      ---
      $world=~s/war/peace/g

      No. In my sample code there is only one class.
        Putting them all in one file doesn't make them one class.