Timeline for How to refactor a lot of Functions that can be run in two different modes
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 6, 2022 at 19:57 | comment | added | Eckehard | Sorry, maybe I misunderstood your question. | |
| Jan 4, 2022 at 2:14 | comment | added | davidbak | Derivation is for an IS-A relationship. One thing IS-A another thing, just more refined. A Giraffe IS-A Mammal which IS-A Animal. It is not the case that Local IS-A Blob and it is also not the case that a Blob IS-A Local. Derivation - i.e., inheritance from a class - is not appropriate. There are other appropriate O-O techniques, e.g., implementation of an interface that would be proper in this case. Or, as you say in your comment, derive from a common abstract class (that implements an interface plus any common behavior). But that's not what you say in your answer. | |
| Jan 4, 2022 at 1:18 | comment | added | Eckehard | Isn't this what you said?: > ...run in one of two modes (in my case server mode and local mode) Inheritance is what happens, if you derive one class from the another: The second one inherits all the properties of the first one. But you can overwrite functions to let the second class behave differently. In this example, it does not matter which class is created first. But there may be situations where you create an abstract class first and derive both from the abstract class. | |
| Jan 3, 2022 at 23:59 | comment | added | davidbak | Is that the way you do it in OO? What does "inheritance" model? Does that relationship show up in the question's code - the difference between "local" and "blob"? For example: given the question, why did you pick "server" to be the superclass instead of "blob"? Couldn't it have been the other way around? You suggest so yourself (the word "say"). Does "inheritance" model that apparently arbitrary choice? | |
| S Jan 3, 2022 at 23:45 | review | First answers | |||
| Jan 4, 2022 at 3:53 | |||||
| S Jan 3, 2022 at 23:45 | history | answered | Eckehard | CC BY-SA 4.0 |