DI(依存性(オブジェクト)の注入)ってこんな感じだったっけ?
正しい記法かどうかや言語がどうとかは適当です。
main() {
Client(Service1()).doSomething()
Client(Service2()).doSomething()
}
class Client {
ServiceInterface _service
Client(this._service)
_service.doSomething()
}
class Service1 implements ServiceInterface {
doSomething() {
print('service1')
}
}
class Service2 implements ServiceInterface {
doSomething() {
print('service2')
}
}
interface ServiceInterface {
doSomething() {}
}
Author And Source
この問題について(DI(依存性(オブジェクト)の注入)ってこんな感じだったっけ?), 我々は、より多くの情報をここで見つけました https://qiita.com/arthur_foreign/items/1194015fe6eeac69b39b著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .