216k views
6 votes
Complete the paragraph below.

In general, it is good practice to_____________ the dependence of classes on each other. This makes it easier to_________ the code if one of the classes is updated.

User Dean Lee
by
3.2k points

1 Answer

8 votes

Answer:

inject, update

Step-by-step explanation:

Dependency injection is a concept in object-oriented programming that links or transfers the functionality of an independent class to a dependent class.

Assuming two classes, Vehicle and Bus are created, the Bus class inherits from the Vehicle. The Bus class is dependent on the Vehicle class and its instances create instances of the Vehicle object.

It is easier and faster to update the Bus class and other classes that inherit from the Vehicle class by updating only the Vehicle class.

User Uyric
by
4.0k points