Design pattern for class reuse and expansion inside another class [closed]











up vote
0
down vote

favorite












Is there a design pattern in OOP (Java specifically) where an existing class or superclass is co-opted as part of another class to reuse some of it's functionality?



The specific problem I am dealing with is I am attempting to implement cut scenes in my game. So far I have planned out that a cut scene will have actors, which will essentially be the moving elements: enemies, the player, etc. These actors will be a separate class and will need to share much of the functionality of the entities they represent, such as movement and animation, but will also need lots of other functionalities that would not fit well in the entity class itself, at least not if you adhere to OOP principles.



The best way I could think to describe it is to encapsulate one class or superclass inside another, but I found it hard to find existing information on this because all I would find was information on encapsulation as an OOP concept and inner classes in Java. Any help would be greatly appreciated, including any general advice in implementing cut scenes in a self-developed game engine.










share|improve this question















closed as too broad by Stephen Kennedy, Machavity, EJoshuaS, TylerH, GBlodgett Nov 11 at 1:00


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • Yes. The decorator pattern.
    – Elliott Frisch
    Nov 10 at 21:51










  • You may consider composition or decorator pattern.
    – Alex Shesterov
    Nov 10 at 21:52












  • Super-class reusing functionality sounds like it could be just inheritance. Always go first for the simple solution if possible. Could also be a Strategy pattern.
    – markspace
    Nov 10 at 22:02










  • markspace - I considered simple inheritance, but when I talk about an "Entity" class that is in fact the superclass of all the entities, if I were to use inheritance I would need to make a subclass for every subclass of Entity which would take ages and would not be very OOP friendly.
    – Julius S
    Nov 11 at 0:26










  • Thank you for the information, I will check out the decorator and strategy patterns in more detail and see how they might apply to my problem.
    – Julius S
    Nov 11 at 0:47















up vote
0
down vote

favorite












Is there a design pattern in OOP (Java specifically) where an existing class or superclass is co-opted as part of another class to reuse some of it's functionality?



The specific problem I am dealing with is I am attempting to implement cut scenes in my game. So far I have planned out that a cut scene will have actors, which will essentially be the moving elements: enemies, the player, etc. These actors will be a separate class and will need to share much of the functionality of the entities they represent, such as movement and animation, but will also need lots of other functionalities that would not fit well in the entity class itself, at least not if you adhere to OOP principles.



The best way I could think to describe it is to encapsulate one class or superclass inside another, but I found it hard to find existing information on this because all I would find was information on encapsulation as an OOP concept and inner classes in Java. Any help would be greatly appreciated, including any general advice in implementing cut scenes in a self-developed game engine.










share|improve this question















closed as too broad by Stephen Kennedy, Machavity, EJoshuaS, TylerH, GBlodgett Nov 11 at 1:00


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • Yes. The decorator pattern.
    – Elliott Frisch
    Nov 10 at 21:51










  • You may consider composition or decorator pattern.
    – Alex Shesterov
    Nov 10 at 21:52












  • Super-class reusing functionality sounds like it could be just inheritance. Always go first for the simple solution if possible. Could also be a Strategy pattern.
    – markspace
    Nov 10 at 22:02










  • markspace - I considered simple inheritance, but when I talk about an "Entity" class that is in fact the superclass of all the entities, if I were to use inheritance I would need to make a subclass for every subclass of Entity which would take ages and would not be very OOP friendly.
    – Julius S
    Nov 11 at 0:26










  • Thank you for the information, I will check out the decorator and strategy patterns in more detail and see how they might apply to my problem.
    – Julius S
    Nov 11 at 0:47













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Is there a design pattern in OOP (Java specifically) where an existing class or superclass is co-opted as part of another class to reuse some of it's functionality?



The specific problem I am dealing with is I am attempting to implement cut scenes in my game. So far I have planned out that a cut scene will have actors, which will essentially be the moving elements: enemies, the player, etc. These actors will be a separate class and will need to share much of the functionality of the entities they represent, such as movement and animation, but will also need lots of other functionalities that would not fit well in the entity class itself, at least not if you adhere to OOP principles.



The best way I could think to describe it is to encapsulate one class or superclass inside another, but I found it hard to find existing information on this because all I would find was information on encapsulation as an OOP concept and inner classes in Java. Any help would be greatly appreciated, including any general advice in implementing cut scenes in a self-developed game engine.










share|improve this question















Is there a design pattern in OOP (Java specifically) where an existing class or superclass is co-opted as part of another class to reuse some of it's functionality?



The specific problem I am dealing with is I am attempting to implement cut scenes in my game. So far I have planned out that a cut scene will have actors, which will essentially be the moving elements: enemies, the player, etc. These actors will be a separate class and will need to share much of the functionality of the entities they represent, such as movement and animation, but will also need lots of other functionalities that would not fit well in the entity class itself, at least not if you adhere to OOP principles.



The best way I could think to describe it is to encapsulate one class or superclass inside another, but I found it hard to find existing information on this because all I would find was information on encapsulation as an OOP concept and inner classes in Java. Any help would be greatly appreciated, including any general advice in implementing cut scenes in a self-developed game engine.







java oop design-patterns design






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 22:53









bcperth

2,0071513




2,0071513










asked Nov 10 at 21:47









Julius S

72




72




closed as too broad by Stephen Kennedy, Machavity, EJoshuaS, TylerH, GBlodgett Nov 11 at 1:00


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as too broad by Stephen Kennedy, Machavity, EJoshuaS, TylerH, GBlodgett Nov 11 at 1:00


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • Yes. The decorator pattern.
    – Elliott Frisch
    Nov 10 at 21:51










  • You may consider composition or decorator pattern.
    – Alex Shesterov
    Nov 10 at 21:52












  • Super-class reusing functionality sounds like it could be just inheritance. Always go first for the simple solution if possible. Could also be a Strategy pattern.
    – markspace
    Nov 10 at 22:02










  • markspace - I considered simple inheritance, but when I talk about an "Entity" class that is in fact the superclass of all the entities, if I were to use inheritance I would need to make a subclass for every subclass of Entity which would take ages and would not be very OOP friendly.
    – Julius S
    Nov 11 at 0:26










  • Thank you for the information, I will check out the decorator and strategy patterns in more detail and see how they might apply to my problem.
    – Julius S
    Nov 11 at 0:47


















  • Yes. The decorator pattern.
    – Elliott Frisch
    Nov 10 at 21:51










  • You may consider composition or decorator pattern.
    – Alex Shesterov
    Nov 10 at 21:52












  • Super-class reusing functionality sounds like it could be just inheritance. Always go first for the simple solution if possible. Could also be a Strategy pattern.
    – markspace
    Nov 10 at 22:02










  • markspace - I considered simple inheritance, but when I talk about an "Entity" class that is in fact the superclass of all the entities, if I were to use inheritance I would need to make a subclass for every subclass of Entity which would take ages and would not be very OOP friendly.
    – Julius S
    Nov 11 at 0:26










  • Thank you for the information, I will check out the decorator and strategy patterns in more detail and see how they might apply to my problem.
    – Julius S
    Nov 11 at 0:47
















Yes. The decorator pattern.
– Elliott Frisch
Nov 10 at 21:51




Yes. The decorator pattern.
– Elliott Frisch
Nov 10 at 21:51












You may consider composition or decorator pattern.
– Alex Shesterov
Nov 10 at 21:52






You may consider composition or decorator pattern.
– Alex Shesterov
Nov 10 at 21:52














Super-class reusing functionality sounds like it could be just inheritance. Always go first for the simple solution if possible. Could also be a Strategy pattern.
– markspace
Nov 10 at 22:02




Super-class reusing functionality sounds like it could be just inheritance. Always go first for the simple solution if possible. Could also be a Strategy pattern.
– markspace
Nov 10 at 22:02












markspace - I considered simple inheritance, but when I talk about an "Entity" class that is in fact the superclass of all the entities, if I were to use inheritance I would need to make a subclass for every subclass of Entity which would take ages and would not be very OOP friendly.
– Julius S
Nov 11 at 0:26




markspace - I considered simple inheritance, but when I talk about an "Entity" class that is in fact the superclass of all the entities, if I were to use inheritance I would need to make a subclass for every subclass of Entity which would take ages and would not be very OOP friendly.
– Julius S
Nov 11 at 0:26












Thank you for the information, I will check out the decorator and strategy patterns in more detail and see how they might apply to my problem.
– Julius S
Nov 11 at 0:47




Thank you for the information, I will check out the decorator and strategy patterns in more detail and see how they might apply to my problem.
– Julius S
Nov 11 at 0:47

















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Bressuire

Vorschmack

Quarantine