GoConqr has a new look! Let us know what you think.

Flashcards

Inversion of control - dependency injection

Ruth Reynders IP MSP English 8 cards

Inversion of control by developer

Cards in this deck (8)

  1. 1Inversion of controlIn software engineering, inversion of control (IoC) is a design principle in which custom-written portions of a computer program receive the flow of control from a generic framework. A software architecture with this design inverts control as compared to traditional procedural programming: in traditional programming, the custom code that expresses the purpose of the program calls into reusable libraries to take care of generic tasks, but with inversion of control, it is the framework that calls into the custom, or task-specific, code.
    Inversion of control is used to increase modularity of the program and make it extensible, and has applications in object-oriented programming and other programming paradigms.
  2. 2Dependency inversionIn object-oriented programming, the dependency inversion principle refers to a specific form of decoupling software modules. When following this principle, the conventional dependency relationships established from high-level, policy-setting modules to low-level, dependency modules are reversed, thus rendering high-level modules independent of the low-level module implementation details. The principle states:[1]
    A. High-level modules should not depend on low-level modules. Both should depend on abstractions.
    B. Abstractions should not depend on details. Details should depend on abstractions.
    The principle inverts the way some people may think about object-oriented design, dictating that both high- and low-level objects must depend on the same abstraction.
    (avoid new!!)
  3. 3Dependency injectionIn software engineering, dependency injection is a software design pattern that implements inversion of control for resolving dependencies. A dependency is an object that can be used (a service). An injection is the passing of a dependency to a dependent object (a client) that would use it. The service is made part of the client's state. Passing the service to the client, rather than allowing a client to build or find the service, is the fundamental requirement of the pattern.
    Dependency injection allows a program design to follow the dependency inversion principle.
    Object dependency:
    - does not create or finds the dependency by himself
    - does not need to know the details of the dependency
    - dependency is created elsewhere
    - dependency is passed to object
  4. 4Inversion of control by developerInversion of control by developer
  5. 5Inversion of control by springInversion of control by spring
  6. 6Spring bean?The objects that form the backbone of your application and that are
    managed by the Spring IoC container are called beans. A bean is an
    object that is instantiated, assembled, and otherwise managed by a Spring
    IoC container. These beans are created with the configuration metadata
    that you supply to the container, …
    (JavaBeans are classes that encapsulate many objects into a single object (the bean). They are serializable, have a zero-argument constructor, and allow access to properties using getter and setter methods. The name "Bean" was given to encompass this standard, which aims to create reusable software components for Java.)
  7. 7How does spring implements ioc?1. objects define their dependencies:
    - spring: @Autowired
    2. Container:
    - create and manages beans
    - injects dependencies when creating a bean
  8. 8Why does Spring use beans?- Created and managed by the container
    - So that a container knows which type to use:
    config files (XML, annotations)
    Why does Spring use beans?

Information

Description
MSP IP Flashcards on Inversion of control - dependency injection, created by Ruth Reynders on 02/06/2016.
Created by
Ruth Reynders
Views
1
Rating

More on Spring Framework

Feedback

What is it about?

What do you think of the new look?

How do you like it?