We used the internal version of object-oriented coldfusion for a while, and I'm just starting to experiment with cfc and how it should be done ...
If I understand correctly, cfinterface defines the signature of functions, and any class that implements this interface must have its own functions to perform the functions defined in the interface.
I’m kind of trying to do the opposite - the interface not only determines the signature of the function, but also determines the logic of the function, and everything that implements this interface can use its functions without defining it independently. Does this exist besides subclassing?
For example, let's say that you have classes A, B, C, D, which all belong to the class Animal
- A and B can walk
- A and C can talk
- B and D can sleep
- Suppose that the logic of walking, talking, and sleeping (if an object can do this) is the same regardless of the class that executes it
- Ideally, if A and B implement a walking interface, they can walk without defining a separate walking method in each class.
Or borrowing a better example from this java multiple inheritance question
- Pegasus is a mixture of horse and bird because it runs like a horse but flies like a bird.
Is it possible? (I think this is multiple inheritance?)
source
share