Message to self.Calling m1 from m2 where they are the methods of the same class. Preferred relationship is “has-a “.We will be using “this” keyword for invocation. Which means compiler already created an object of the same class within itself.
We can call the method of base class from derived using “super” or “base” keywords which are the objects of base and it is created within the derived class. So we use “is-a” relation but it is implemented through “has-a” relation. But if there is no “is-a” relation between the base and derived class, then those objects won’t be created. So its an equalizer
Accessing from sibling class. Preferred relation is “has-a”.
Peer to peer
Preferred relationship is “has-a ”
Generalization is having both the interface(type contracts etc) and the implementation of the base class.
Realization is having only the interface of the base class and creating their own implementation for the methods in the base class.
In “has-a” relationship, we can use only the implementation of the class, but not its interface.
Finally, we can say generalization =realization +has a
So generalization which is tightly coupled can be replaced with realization and association relationships which will make the classes loosely coupled.This will give the flexibility we need and will give us a good clean design .