Comparative analysis of commonly used flex IOC framework

Source: Internet
Author: User

The IOC (inversion of Control), also known as DI (Dependency injection), is a design strategy that has become very popular in software development in recent years. Numerous flex developers have explored the IOC framework such as spring ActionScript, parsley, FLICC, and SWiZ.

What is the IOC? Word, IOC is a software design model. With IOC, you can use a separate object to populate the correct implementations for the data members of other objects, rather than the objects themselves. There are two advantages to doing this. First, you can declare an object's data member as an interface, thus separating the object from its specific implementation (i.e., contract design, designing by contract). Second, you can remove the creation logic from the object and make the object more explicit.

The IOC container provides a framework in which you can use this pattern in a consistent and declarative manner. By combining this pattern with an interface, you can create objects that are easy to test and use flexibly. For a more in-depth discussion of the IOC model, see Martin Fowler's article "Inversion of control containers and the Dependency injection patterns".

Java and. NET's IOC framework has long been established, and in the flex community, there have been a few recent developments.

This article will discuss how some of the IOC frameworks in flex work, how they are used, and compare these frameworks. For convenience, I'll use spring ActionScript, parsley, FLICC, and swiz frameworks in the same project (Profileviewer).

Concept of the IOC

There are generally two most common methods of object configuration:

Object Instantiation (for example: var myObject = new Object ())

Object Lookup (for example: var myObject = Registry.getmyobject ())

With IOC, you can instantiate the objects that your application uses in a separate layer and pass in the dependencies they need. In particular, the most common implementations are two ways:

Setter injection (for example: Instance.myobject = new Object ())

constructor injection (for example: instance = new instance (new Object ())

An IOC framework, usually consisting of the following three components: Configuration, factory, and injection mechanism.

Configuration

We can describe the relationship between objects in the configuration. The most commonly used configuration description method is declared in a file. Such files are sometimes referred to as contextual files (context file). You can also use metadata/annotations (metadata/annotation) and even describe the configuration directly in your program. /

Factory

The factory is responsible for the parsing of the configuration and the preparation of all objects, and once the program has been run, the objects can be obtained as needed.

In the classic spring framework (the most popular Java IOC framework), all objects (I call them client objects) are prepared by the IOC container, and they declare their dependencies in an interface form. In the configuration file, the declared dependencies are set to the corresponding implementation class.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.