IOC

xiaoxiao2021-03-06  38

IOC is not a new thing, nor a unique function of which language is just a collaborative and organizational mode mainly used to resolve the injection structure injection (constructor) of interface parameters (constructor) value injection (GET / SET) interface injection That is to say that the caller and service provider define an agreement) The method of interface injection is because the object is still highly coupling, so the application is not very widely constructed injecting and setting value injection reflects a common problem for object-oriented programming. Where to fill the object's field, is the value when creating an object or by an attribute or method. Martin Fowler recommends creating a legitimate object when the object is constructed, so that there is still a benefit that you can hide the uncomfortable field (Note: or you should change the field during run), and publish a setting method, Means the caller can freely change the value of the field. There are too many parameters, and the structural injection makes the system a bit messy, and sometimes there is no way to use constructive injection.

转载请注明原文地址:https://www.9cbs.com/read-69031.html

New Post(0)