in reply to Re: Re5: Constructor/Factory Orthodoxy
in thread Constructor/Factory Orthodoxy

"new" means to make a completely new one. Cloning doesn't mean to make a new one. It means copy this one. The big difference is when the object has a list of other objects contained within it. What does clone mean in this case? Does A and B both point to the same list (shallow copy)? Does B have its own list, each with clones of those contained objects (deep copy)? It's not clear, and that's because a given application might want either behavior, or something completely different. When something isn't clear, it should be made clear. Making it clear, in my mind, involves different methods. Maybe they share a bunch of stuff under the hood, but that's a good thing. There should be different presentations for different actions, though.

"That line", as you put it, removes the distinction between the two concepts. That's not so good. Also, if you asked most people who used it, they would have no idea why that line was there, what it was good for, and what behaviors it allowed/disallowed. That is what my angina is about. If you write a line, you should know what that line does.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
Re: Re7: Constructor/Factory Orthodoxy
by Abigail-II (Bishop) on Feb 27, 2003 at 14:40 UTC
    Well, you were the one who thought that
    my $class = ref $this || $this;

    meant cloning. It wasn't suggested by the OP, nor is it suggested by most people using this construct. I fully agree that cloning is something you only should do in very specific cases (and you'd need the full cooperation of all classes in the inheritance tree). It's easier to fix your perception than all the code using it.

    However, I don't find that an argument against the quoted contruct. It only gets confusing because you assign a totally different meaning to the construct then the construct is. That doesn't make the construct wrong. The only thing that's wrong is your perception of it.

    Abigail