Relations Between Objects - Dependency
In the section "Relations Between Objects" part "Dependency", you wrote.
"""
Dependency is the most basic and the weakest type of relations between classes.
There is a dependency between two classes if
some changes to the definition of one class might result in modifications to another class.
Dependency typically occurs when
you use concrete class names in your code.
For example, when
specifying types in method signatures, when
instantiating objects via constructor calls, etc.
You can make a dependency weaker if
you make your code dependent on interfaces or abstract classes instead of concrete classes.
"""
With the example
```cpp
class Interface {
};
class Concrete: public Interface {
};
class App { // App --> Interface, App -(weaker)-> Concrete
public:
void fun(Interface interface) { // make code dependent on interface
}
};
```
I understand that the App class is dependent on Interface, and dependent weaker with Concrete class.
Is it right or wrong?Best regards,
Customer support service by UserEcho
Hi!
Yes, it's all correct.