0
Under review

Relations Between Objects - Dependency

manh duong 8 months ago updated by Alexander Shvets 8 months ago 1
Hello,

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,


Under review

Hi!

Yes, it's all correct.