Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
If there is a possibility that the class may be replaced by another in the future or already several classes with a common interface are connected under different conditions
1. If some kind of abstraction can be pulled out of the class. For example, the abstraction "stream" can be pulled out of the "file" object. Private - The Project object implements the Modifiable interface with two functions: modify() and isModified().
2. To simplify unit testing under the condition of ownership.
Suppose we have a class "class" (school) and a class "student". The student knows what class he is in.
In such a situation, a “tangle” is obtained: if you need to make a student, then you need to make a class.
This vicious circle can be broken by making the ISchoolClass interface and deriving a class from it. When unit testing, we replace the class with some kind of stub.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question