Answer the question
In order to leave comments, you need to log in
What is property injection?
dependency injection is divided into 3 types:
1. constructor injection. in this case, the dependency is passed through the class constructor and then assigned to the class property
class A:
def __init__(self, logger):
self.logger = logger
class A:
def set_logger(self, logger):
logger_obj = logger
logger_obj.write('blabla')
Answer the question
In order to leave comments, you need to log in
Changing the public variable in which the embedded object lies. More precisely, the replacement of this object.
a = new A();
a.logger = new Logger();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question