IOC and AOP understanding

Transfer from  https://blog.csdn.net/qq_38006047/article/details/80797386

1, understand the "inversion of control"

   Inversion of Control, also called dependency injection, one design concept of the object oriented programming, to reduce the coupling between the code.

  Coupled program: dependency caller and the callee.

 For example: A programmer is responsible for the preparation of class A, B programmer responsible for the development of class B, class A certain features need to be an object pear class B calls its method to complete, it will depend on the class A category B, if B is not a programmer A programmer writing class B Do you want to wait forever?

 Principles of corporate development: "Do not rely on compile time until run time reliance"

// so-called Class A Class dependent B 
public  class PersonServiceBean {
       Private the PersonDao PersonDao = new new PersonDaoBean (); 
  
      public  void Save (the Person Person) { 
            personDao.save (Person); 
      } 
}

PersonDaoBean is created and maintained within the application.

The so-called "inversion of control" is the application itself is not responsible for object creation and maintenance of dependent, dependent objects are created and maintained by the outer container is responsible. Such control would apply to the transfer from the outside of the container, transfer the so-called inversion of control.

 

Guess you like

Origin www.cnblogs.com/Oldz/p/11038366.html