395 reputation
210
bio website
location Germany
age 42
visits member for 3 years, 3 months
seen Jun 27 at 18:18

Software Engineer. Mostly Java atm.


Sep
24
awarded  Autobiographer
Aug
24
awarded  Good Question
Sep
12
awarded  Yearling
Jun
2
accepted What are the alternatives to “overriding a method” when using composition instead of inheritance?
Jun
2
comment What are the alternatives to “overriding a method” when using composition instead of inheritance?
I think my own answer goes in the direction you proposed. It just goes into more details by giving a complete working example.
Jun
2
answered What are the alternatives to “overriding a method” when using composition instead of inheritance?
Jun
1
comment What are the alternatives to “overriding a method” when using composition instead of inheritance?
+1 This is what I'm trying to "formalize" atm. I have to first define a bunch of test-cases to see if all corner cases are supported. BTW: I didn't know the same person could give several answers to the same question!
May
31
comment What are the alternatives to “overriding a method” when using composition instead of inheritance?
@kevincline +1 You have a good point there. If I have to pay a lot in performance and memory to implement this, I may as well use a dynamic language that makes it easy to do.
May
31
revised What are the alternatives to “overriding a method” when using composition instead of inheritance?
Clarifed problem to be solved, so that I get more relevant answers.
May
31
comment What are the alternatives to “overriding a method” when using composition instead of inheritance?
I do not agree with you. My question was not a debate about whether to prefer composition over inheritance, or the other way around, as you seem to have taken it. There are several other questions like that out there, most of which got negative votes. I have already chosen composition, and I am not ready to discuss this choice. I want to know how to solve, using composition, the problems that inheritance normally solve, and that is exactly what I have asked. No need for a different question.
May
31
comment What are the alternatives to “overriding a method” when using composition instead of inheritance?
What you suggest is what I meant by "One extreme alternative that would ..." I know that it is possible and would work, but it would probably (in the case of Java) multiply the whole memory footprint by at least 4 times. A Java int is 4 bytes, a java.lang.Integer (the object form of an int), plus reference is at least 20 bytes in 64 bits, if I get it right. That is the main downside. Memory is cheap, but not that cheap.
May
31
comment What are the alternatives to “overriding a method” when using composition instead of inheritance?
I see that this is not getting me anywhere. Please look at my comment to @GordonM . I have no choice.
May
31
comment What are the alternatives to “overriding a method” when using composition instead of inheritance?
@GordonM You don't need to convince me. I prefer inheritance, but for the problem I am trying to solve, (changing the type of an object at runtime), it just doesn't cut it.
May
31
asked What are the alternatives to “overriding a method” when using composition instead of inheritance?
Mar
11
awarded  Critic
Feb
10
accepted Where can I find good example of techniques to compact data in-memory?
Feb
8
asked Where can I find good example of techniques to compact data in-memory?
Nov
19
awarded  Popular Question
Nov
15
comment Is there a language or design pattern that allows the *removal* of object behavior or properties in a class hierarchy?
For the records, I chose this answer because it answers the title of the question literally, as well as giving a better alternative. But I found other answers equally as good with this one.
Nov
15
accepted Is there a language or design pattern that allows the *removal* of object behavior or properties in a class hierarchy?