on Spring IoC Container

quick layman’s analogy:

Imagine Spring IoC Container as a computer shop where it sells various computer components. A customer now wants to work with a computer - so he asks the shop .. “hey I want a Desktop”

Computer desktop = context.getBean(Desktop.class);

In response to this request, the shop will supply and assemble components (such as RAM, SSD, Power Supply, GPU, etc.) that make up the Desktop. This assembly process (aka. Dependency Injection) is guided by a “manual” - in form of an XML file or annotations within the codes. Which ultimately leads to the creation of a fully functional Desktop.

The shop alleviates the need for the customer (who might not even know how to build his own Desktop) to manually go through the process of assembling the Desktop. Moreover, the customer doesn’t need to worry about where to purchase the components because these are all supplied by the shop

Allowing an outside system to do things for you (consistently) pretty much sums up the concept of Inversion of Control

要查看或添加评论,请登录

Rainier Buccat的更多文章

  • on NodeJS

    on NodeJS

    web development landscape has evolved over the past years and Javascript via NodeJS has proven to be one of the best…

社区洞察

其他会员也浏览了