Considering that the newName method is currently called only during the
creation of a new MailImpl object I think that a third solution would be
better.
Add a constructor to MailImpl:
public MailImpl(Mail original) that simply create a newName and then
calls this(original, newName(original));
We don't use the duplicate because we can't assume the originalMail is a
MailImpl as the contract is that we receive a Mail object.
Stefano
Noel J. Bergman wrote:
I really don't like this change.
I'd suggest moving newName to MailImpl, and hiding the random there, too. Then
you could revert the calling code to the way it was, except for changing from
newName(originalMail) to MailImpl.newName(originalMail).
But even better, we already have
public Mail duplicate() { ... }
public Mail duplicate(String newName) { .. }
we could add:
public Mail duplicate(boolean newName) {...}
and call that, rather than the constructor directly:
- MailImpl newMail = new MailImpl(originalMail,newName(originalMail));
+ MailImpl newMail = (MailImpl) originalMail.duplicate(true);
--- Noel
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]