I have always advocated the use of standardized api, and currently use it on my code. However i always get very strong resistance when it comes to code review, even on projects i have designed and built from scratch which there is no existing code that i will conflict with.

I use standardized API to insure that i am in complete control of the architecture.

One example is the use of JSR-330 inject, i use @inject, @named, etc... Instead of spring specific @autowire and @qualifier, this is to insure that my business code remain as immutable as possible.

They could not seem to pick up when i explain, their arguments are usually:

  • Spring is a lot more modern, or that's 2009 according to my Google search.

  • If they get cornered, it becomes: Well just use code we already use, so we can understand it quickly.

I'm not discounting that i may be wrong, so i am interested in hearing other people's opinions.


The most important thing in any project is consistency. If your entire project is build around JSR-330, is consistently using it, and it is not introducing unnecessary work to program using it (having to remember to use Inject instead of Autowired does not count as unnecessary work), as compared to e.g. direct Spring annotations, then one should stick to JSR-330 annotations. And forcing to mix them up just because I'm used to other type is a very weak argument.

Unless there's a collective effort (which is agreed upon) to globally change JSR-330 annotations to those of e.g. Spring, the JSR-330 should stay. But this applies vice versa: if a project is using Spring's annotations, it should keep using those.

Components such as CDI are components which are extremely unlikely to change over time. E.g. if your project is running on Spring, the chance you would migrate to a completely different framework (pretty much the only situation where you would benefit from using JST-330 instead of Spring's CDI annotations) is close to 0. And even if such migration to a completely different project happened, having to change the used CDI annotations would be the least of your troubles.

Additionally, if you're a sole developer building a project from scratch, it's your decision which approach you choose. And if a certain developer joins the projects after a substantial development period, the developer should acknowledge your decision and use the approach you've chosen.

On the other hand, if you're building a project from scratch and you're not the only developer working on it, the project is a team effort. The approach should be discussed among all participants and based on that the approach the most comfortable to the majority of developers should be chosen (unless a certain individual can present an extremely strong argument in order to use a different approach - and this usually does not happen).

  • Of course consistency is very important, however on a project built from scratch using standardized components, i still get this resistance. – user3414321 Oct 18 '20 at 6:34
  • My problem with vendor specific api is they tend to influence architecture, which in my belief should remain independent no matter what. – user3414321 Oct 18 '20 at 6:36
  • 1
    @user3414321, I have updated my answer a little bit. To address your architecture concern, that's not really true. An annotation type hardly affects which architecture and development approach you use for the project (just one of many examples, you can use SOA and DDD when using either JSR-330 annotations or Spring's). – Andy Oct 18 '20 at 6:44
  • @Andy the whole point of standardized annotations is to avoid using vender specific features which are designed to impose vender lock in. The wise move here is not to just use what everyone is using. This is selling you soul for a moment of convince. – candied_orange Oct 19 '20 at 3:40
  • @candied_orange If I come to an already running project which uses Spring's annotations, my solution is hardly going to be to replace all Spring's annotation with those from standard namespaces. Especially regarding Spring, which is the de-facto standard in today's Java world. Sure, for green field projects, it is better to choose the standardised annotations, but even then you're likely to lock yourself to a certain framework, out of which the annotations used are the least of your problems. – Andy Oct 19 '20 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.