论据反对注解 [英] Arguments Against Annotations

查看:130
本文介绍了论据反对注解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队正在向Spring 3.0的,有一些人谁想要开始一切迁入注解。我刚刚得到一个非常不好的预感在我的内心,当我看到有这样的方法的类(code味道?):(只是举个例子 - 不是所有的真正的注释)

My team is moving to Spring 3.0 and there are some people who want to start moving everything into Annotations. I just get a really bad feeling in my gut (code smell?) when I see a class that has methods like this: (just an example - not all real annotations)

@Transaction
@Method("GET")
@PathElement("time")
@PathElement("date")
@Autowired
@Secure("ROLE_ADMIN")
public void manage(@Qualifier('time')int time) {
...
}

我只是落后于时代,还是做这一切似乎是一个可怕的想法给其他人?而不是使用面向对象的概念,如继承和多态性现在一切按约定或通过注释。我只是不喜欢它。无需重新编译所有的code改变的事情,海事组织的配置似乎是错误的。但是,这似乎是一切的方式(特别是春节)是怎么回事。我是不是应该克服它,或者我应该推回,并尽量保持我们的code作为注解尽可能免费?

Am I just behind the times, or does this all seem like a horrible idea to anyone else? Rather then using OO concepts like inheritance and polymorphism everything is now by convention or through annotations. I just don't like it. Having to recompile all the code to change things that IMO are configuration seems wrong. But it seems to be the way everything (especially Spring) is going. Should I just "get over it" or should I push back and try to keep our code as annotation free as possible?

推荐答案

其实我觉得不好的感觉在你的肠道对更多的是一个像code此混合配置注释。

Actually I think that the bad feeling in your gut against has more to do with Annotations like this mixing configuration with code.

我个人有同样的感觉,你做什么,我会preFER离开配置(如交易的定义,路径元素,一个控制器应该映射到网址等)的code之外基地本身和外部的Spring XML上下文文件。

Personally I feel the same way as you do, I would prefer to leave configuration (such as transaction definitions, path elements, URLs that a controller should be mapped to, etc.) outside of the code base itself and in external Spring XML context files.

我觉得虽然这里虽然正确的做法归结到意见和方法,你preFER - 我predict一半的社区将与标注方法,而另一半同意将与外部认同配置方法。

I think though that the correct approach here though comes down to opinion and which method you prefer - I would predict that half the community would agree with the annotations approach and the other half would agree with the external configuration approach.

这篇关于论据反对注解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆