-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Prototype pattern re-factor #584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @panksy2k , public Beast clone() throws CloneNotSupportedException { Then if we call clone method on an object of ElfBeast, it will return an Object of type Beast, not ElfBeast. That is why, clone() implementation should be in ElfBeast class. |
@panksy2k @ghost, |
Pull request description It.s seems the equal() method in the abstract class isn't designed properly and I make some change in these abstract classes and their subclasses. for issue: iluwatar#584
Under construction by https://github.com/jasciiz |
@jasciiz can you please share any progress you have made for this issue? |
Sure thing @barathgdkrish. Please mention a timeline for when can we expect a PR against this issue. |
Hey @ohbus, @barathgdkrish is still working on this or shall I start with this? |
How about adding a default method in typed prototype abstract class itself?
Doing changes with respect to this class works fine and all test were passed. Not sure whether this is a good practice or not. |
Hi, if noone else is working on this, I could pick up this issue. Is that okay? :) |
Yes, since there is no sign of PR from @barathgdkrish you can go ahead @ThexXTURBOXx |
…watar#584) This commit refactors the Prototype pattern by making it Cloneable and thus inheriting the clone() method to its subclasses which removes code duplications.
…watar#584) This commit refactors the Prototype pattern by making it Cloneable and thus inheriting the clone() method to its subclasses which removes code duplications.
…watar#584) This commit refactors the Prototype pattern by making it Cloneable and thus inheriting the clone() method to its subclasses which removes code duplications.
…watar#584) This commit refactors the Prototype pattern by making it Cloneable and thus inheriting the clone() method to its subclasses which removes code duplications.
…watar#584) This commit refactors the Prototype pattern by making it Cloneable and thus inheriting the clone() method to its subclasses which removes code duplications.
There's a pr for the fix, but it seems that SonarCloud isn't happy with the try-catch of the |
Hi,
The Prototype implementations where clone() is Overridden (ElfBeast, ElfMage etc) can rather not have implementation of clone(). Instead their respective parent class (Mage, Beast) can have a general implementation of clone which creates a new instance by doing a shallow copy (Object.clone()) and then subsequently type-cast to the type of class (Mage.class or Beast.class etc) it is cloning for.
This will have advantage of:
Removing verbosity among all implementations and dedicate the responsibility of cloning the object by their respective interfaces (abstract class).
Avoid using 'new' more than once and using only whilst cloning the prototype object that is passed in HeroFactoryImpl.
Regards,
panksy2k
The text was updated successfully, but these errors were encountered: