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

Software Engineer. Mostly Java atm.


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
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
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.
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
comment Is there a language or design pattern that allows the *removal* of object behavior or properties in a class hierarchy?
I quite like your answer. I think it deserves more votes.
Nov
15
comment Is there a language or design pattern that allows the *removal* of object behavior or properties in a class hierarchy?
+1 in general, and in particular for the "mammoth". LOL!
Sep
17
comment How do you call a “Proxy” that delegates to *several* implementations?
And while I agree with your answer (+1), I'll go with Marjan. A Facade doesn't stop being a Facade because it expose the same interface as the objects it delegates to.
Sep
17
comment How do you call a “Proxy” that delegates to *several* implementations?
I don't think Mediator is correct either, because it's goal is to "prevent" the different objects implementing the behavior to "know each other". But in my proposed design, I don't want to prevent FragmentB of knowing FragmentA, I just want to enable FragmentB to exist without knowing the concrete implementation of FragmentA.
Sep
13
comment Is there a specific design strategy that can be applied to solve most chicken-and-egg problems while using immutable objects?
I'm not actually trying to use "functional language" because I just don't get it! The only thing I normally retain from any non-trivial functional programming example is: "Damn, I which I was more clever!" It's just beyond me how this can make sense to anyone. From my students days, I remember that Prolog (logic-based), Occam (everything-runs-in-parallel-by-default) and even assembler made sense, but Lisp was just crazy stuff. But I do get you point of moving the code that cause a "state change" outside the "state".
Sep
13
comment Is there a specific design strategy that can be applied to solve most chicken-and-egg problems while using immutable objects?
@Rachel Strictly speaking, they aren't proper singletons, and I don't use static, but rather an "object registry" (OSGi). OTOH, this got me thinking. Traditionally, in a tree-shaped data-model, the "parents" know the "children", so the problem is only when the children need to know the parent or siblings. But if the roots of the tree are accessible "from anywhere" (either through static, or the "object registry" in my case, the child can get a reference to anything by traversing the data-model, so that IS a solution (although a complex and expensive one).
Sep
13
comment Is there a specific design strategy that can be applied to solve most chicken-and-egg problems while using immutable objects?
The answer to this other question seem to confirm my suspicion that things get complicated really quickly with immutables: programmers.stackexchange.com/questions/68058/…
Sep
13
comment Is there a specific design strategy that can be applied to solve most chicken-and-egg problems while using immutable objects?
@DeadMG Well, OK. They are not real Java Singletons. I just mean that there is no point to create more than one instance of each, since they are immutable and would be equal to each other. In fact, I won't have any real static instances. My "root" objects are OSGi services.
Sep
13
comment Is there a specific design strategy that can be applied to solve most chicken-and-egg problems while using immutable objects?
Yes, this is what I do, but how do I get blocklist? Obviously, the blocks have to be created before the list of blocks, and therefore, if the block is really immutable, it cannot receive the list of blocks as parameter. So where doe it get the list from? My general point is, by making the code more convoluted, you solve the chicken-and-egg problem at one level, just to get it again at the next. Basically, I see no way of creating a whole application based on immutability. It seems only applicable to the "small objects", but not to containers.
Sep
12
comment How to design a system that allows for multiple parallel extensions of the same “component”?
Well, I think that this applies to many games. The problem is "as long as they weren't overriding assets". Very many mods do precisely that, and without this ability, modding isn't have as interesting. Without "overriding", plain OSGi would do everything i need.
Sep
12
comment Is there a specific design strategy that can be applied to solve most chicken-and-egg problems while using immutable objects?
I know this would make more "scientific sense", but in a game it's easier to model it as two different material with "fixed" properties, rather than one material with "variable" properties depending on the context.
Sep
12
comment Is there a specific design strategy that can be applied to solve most chicken-and-egg problems while using immutable objects?
(assuming I understood Haskell's syntax) I think my current solution is actually very similar, but I was wondering if it was the "right one", or if something better exists. First I create an "handle" (reference) for every (not-yet-created) object, then create all objects, giving them the handles they need, and finally initializes the handle to the objects. The objects are themselves immutable, but not the handles.