Decorator Pattern with multiple concrete components
up vote
0
down vote
favorite
Currently I want to implement a Decorator Pattern in a static language. Consider the following structure:
Entity <-------- Decorator
^ ^ ^
| | |
| | |
Shape Group ConcreteDec
When I only have a ConcreteDec
, I am unable to call Group.add(Entity)
, a function that is defined in Group
, but isn't inherited from Entity
. Shape
isn't a class that could add anything; Shape
can't have members, that wouldn't make sense. Inheriting add(Entity)
from Entity
in Shape
wouldn't be an option.
Is there a way to call add(Entity)
from ConcreteDec
without breaking Shape
nor the decorator pattern?
decorator
add a comment |
up vote
0
down vote
favorite
Currently I want to implement a Decorator Pattern in a static language. Consider the following structure:
Entity <-------- Decorator
^ ^ ^
| | |
| | |
Shape Group ConcreteDec
When I only have a ConcreteDec
, I am unable to call Group.add(Entity)
, a function that is defined in Group
, but isn't inherited from Entity
. Shape
isn't a class that could add anything; Shape
can't have members, that wouldn't make sense. Inheriting add(Entity)
from Entity
in Shape
wouldn't be an option.
Is there a way to call add(Entity)
from ConcreteDec
without breaking Shape
nor the decorator pattern?
decorator
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Currently I want to implement a Decorator Pattern in a static language. Consider the following structure:
Entity <-------- Decorator
^ ^ ^
| | |
| | |
Shape Group ConcreteDec
When I only have a ConcreteDec
, I am unable to call Group.add(Entity)
, a function that is defined in Group
, but isn't inherited from Entity
. Shape
isn't a class that could add anything; Shape
can't have members, that wouldn't make sense. Inheriting add(Entity)
from Entity
in Shape
wouldn't be an option.
Is there a way to call add(Entity)
from ConcreteDec
without breaking Shape
nor the decorator pattern?
decorator
Currently I want to implement a Decorator Pattern in a static language. Consider the following structure:
Entity <-------- Decorator
^ ^ ^
| | |
| | |
Shape Group ConcreteDec
When I only have a ConcreteDec
, I am unable to call Group.add(Entity)
, a function that is defined in Group
, but isn't inherited from Entity
. Shape
isn't a class that could add anything; Shape
can't have members, that wouldn't make sense. Inheriting add(Entity)
from Entity
in Shape
wouldn't be an option.
Is there a way to call add(Entity)
from ConcreteDec
without breaking Shape
nor the decorator pattern?
decorator
decorator
asked Nov 10 at 22:07
jallersma
115
115
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243901%2fdecorator-pattern-with-multiple-concrete-components%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown