Friday, 15 May 2015

java - Properly extending classes from existing classes, design pattern? -


I am trying to explain the best way to create new classes which share common functionality from existing classes,

  Extension of actor in the actor group [/ code>  

These classes can not be converted to size or form in any way because they are jars Files are I

I just add my functionality to these sections MyActor has expanded: Actor extends MyGroup group

But I found I was repeating a lot of code because both (classes) Essentially the actor is.

How do I do a class in Java that can be obtained both by both MyActor and MyGroup, ensuring that they get from actor and group respectively.

You can solve this problem by creating an actor and group interface, In this way, you can declare methods and variables, and still fill them in different ways in each class, if needed, you can make one of only one interface. It really depends on you, though I want to create an interface group.


No comments:

Post a Comment