注释VS XML,优点和缺点 [英] Annotations vs XML, advantages and disadvantages
问题描述
我是新来的Java在这里,我正在读关于注释和XML,我个人发现XML有喜欢的话可以申请外放,可以不用重新编译的类文件进行很多优势的变化。如果我使用的标注,如果我需要做出改变需要去源$ C $ c和重新编译应该做的。如果是这样的情况下,我们为什么要使用注释
i am new to java here, I was reading about annotations and xml, personally I find out xml has lot of advantages like it can be put outside application, changes can be made without recompiling class files. If i use annotations if I need to make changes need to go to source code and recompiling should be done. If this is the case why should we use annotations
推荐答案
注释的优点:
1)的所有信息在一个文件中(无需打开两个文件以配置一个给定的行为)
2)当类的变化,无需修改XML文件
1) All the information is in a single file (no need to open two files to configure a given behavior)
2) When the class changes, no need to modify the xml file
XML文件的优点:
1)POJO和行为之间清晰的分离
2)当你不知道哪个POJO负责的行为,很容易发现,POJO(在文件中的一个子集搜索,而不是所有的源$ C $ C)
1) Clear separation between the POJO and its behavior
2) When you do not know which POJO is responsible for the behavior, it is easier to find that POJO (searching in a subset of files rather than all the source code)
这篇关于注释VS XML,优点和缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!