Spring Actionscript, Dawn, SmartyPants, Swiz, Spicelib (used by Parsley) and SwiftSuspenders (used by Robotlegs) perform Dependency Injection.
Moreover they can all perform automatic DI by parsing class metadata. It would be grand if the common DI related metadata tags could be standardised. That way we really could write code that is decoupled from any particular framework.
Dawn, Swiz, Spicelib, SwiftSuspenders, SmartyPants: [Inject] (above property, setter or method)
Spring AS: [Autowire] (above property, setter or method)
[Inject] by 5
[Inject] is clear and simple and used by almost all of the libraries. It also directly correlates to @Inject from the JSR-330 Dependency Injection for Java specification. Let’s use it.
Dawn, SwiftSuspenders, SmartyPants: [Inject(name=“SomeName”)] (above property, setter or method)
Swiz: [Inject(source=“SomeName”)] (above property, setter or method)
Spicelib: [Inject(id=“SomeName”)] (above property, setter or method)
Spring AS: [Autowired(name=“SomeName”)] (above property, setter or method)
[Inject(name=“SomeName”)] by 3
Since you can define default attributes best practice could be to leave out the attribute: [Inject(“SomeName”)]
SwiftSuspenders: [Inject] (above class)
Spicelib: [InjectConstructor] (above class)
Swiz, Spring AS, Dawn: ?
?
I don’t see the need for an extra tag ([InjectConstructor]) when we could simply use [Inject].
Dawn, SwiftSuspenders, SmartyPants, Swiz: [PostConstruct] (above method)
Spicelib: [Init] (above method)
[PostConstruct] by 4
@PostConstruct is used in Java for the same purpose. Let’s use the most popular, established one.
SwiftSuspenders, SmartyPants, Dawn: none?
Swiz: [PreDestroy] (above method)
Spicelib: [Destroy] (above method)
@PreDestroy is used in Java for the same purpose. Let’s use the most familiar, established one.
SwiftSuspenders, SmartyPants, Swiz: none?
Dawn: [Provider] (above method)
Spicelib: [Factory] (above method)