`
leonzhx
  • 浏览: 794087 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Item 35: Prefer annotations to naming patterns

阅读更多

1.  Prior to release 1.5, it was common to use naming patterns to indicate that some program elements demanded special treatment by a tool or framework. Naming patterns has several big disadvantages. First, typographical errors may result in silent failures. A second disadvantage of naming patterns is that there is no way to ensure that they are used only on appropriate program elements. A third disadvantage of naming patterns is that they provide no good way to associate parameter values with program elements.

 

2.  An annotation is called a marker annotation, if it has no parameters but simply “marks” the annotated element.

 

3.  Annotations never change the semantics of the annotated code, but enable it for special treatment by other tools.

 

4.  If a reflective method call throws an exception, the reflection facility wraps it in an InvocationTargetException, which can be extracted from the InvocationTargetException.getCause method.

 

5.  The syntax for array parameters in annotations is flexible. It is optimized for single-element arrays. Single element argument is still valid with the array-parameter version and result in single-element arrays. To specify a multiple-element array, surround the elements with curly braces and separate them with commas.

 

分享到:
评论

相关推荐

    Effective Java 3rd edition(Effective Java第三版英文原版)附第二版

    Item 39: Prefer annotations to naming patterns Item 40: Consistently use the Override annotation Item 41: Use marker interfaces to define types 7 Lambdas and Streams Item 42: Prefer lambdas to ...

    专享:prefer的用法__(全).pdf

    13. “I would prefer to spend the weekend at home rather than driving all the way to your mother’s.”说话者宁愿在家度过周末,而不愿长途驾车去对方母亲家。 14. “I should prefer beef rather than ...

    Effective C#

    **Item 22: Prefer Defining and Implementing Interfaces to Inheritance** - **Reasons:** Interfaces promote loose coupling and make it easier to swap implementations. - **Implementation:** ```csharp ...

    effective c++

    5. **Item 35: Make sure you have a destructor if you have a pointer member that is not a standard container element** - **核心观点**:如果类中包含指针成员(非标准容器元素),则需要定义析构函数来释放...

    Copy Constructors and Assignment Operators终极解释

    在C++编程语言中,复制构造函数(Copy Constructor)和赋值运算符(Assignment Operator)是两个非常关键的概念,特别是在处理对象的拷贝和赋值时。它们默认由编译器提供,但通常需要根据具体需求进行自定义,以确保正确...

    新人教九年级英语unit单词讲解PPT课件.pptx

    4. **特定情况**:`prefer to do sth.` 用于强调在特定情境下,更愿意做某事,例如:"I prefer to walk."(我宁愿走路。) 5. **对比形式**:`prefer doing sth. to doing sth.` 这种结构表示在两个动作之间,更...

    介词to的用法归纳.pdf

    * prefer to * compare to * contrast to 这些例句中,to表示比较或对比的意思,强调两者之间的差异或相似性。 五、tҏ 与 及 个 别 的 名 词 构 成 比 较 之 意 在这个用法中,to与及个别的名词构成比较之意。...

    安徽省太和县北城中心学校九年级英语全册Unit9IlikemusicthatIcandancetoSectionA1a_2d导学

    3. prefer sth to sth,如:I prefer fish to meat. 或 I prefer reading to playing. 通过以上内容的学习,学生应能理解并运用这些词汇和语法结构,进行关于音乐喜好的交流,同时也能理解和使用定语从句,提升英语...

    九年级英语下册 Unit 6 Topic1 ABCD学案(无答案) 仁爱版

    - 宁愿…也不…:prefer…to… - 儿童节目:children's program - 新闻报道:news report - 体育节目:sports program - 教育节目:educational program - 娱乐节目:entertainment program - 爱上…:fall ...

    ESLint 规则文件

    ESLint是针对javascript代码的静态检查工具。资源是本人配置的ESLint 规则文件。官方文档:http://eslint.org/docs/rules/。

    初中要用到的固定搭配.docx

    - prefer to do sth / preferring doing sth.: 更喜欢做某事,如:I prefer to walk / I prefer walking. - begin to do sth / beginning doing sth.: 开始做某事,如:She began to cook / She began cooking. -...

    高考英语重点词组固定搭配大全.docx

    to do sth.:宁愿某人做某事,如:I prefer you to come earlier. 28. request sb. to do sth.:要求某人做某事,如:The client requested us to revise the design. 29. remind sb. to do sth.:提醒某人做某事,...

    schemalint:Lint数据库架构

    public.actor.first_name: error prefer-text-to-varchar : Prefer text to varchar types 用法 安装方式: $ npm i -g schemalint 要运行,请确保您位于具有.schemalintrc.js配置文件的文件夹中,然后键入: $ ...

    2013年九年级英语下册 Module 8 On the town动词不定式专项练习 外研版

    解析:"prefer to do... rather than do..." 表示宁愿做...而不愿做...,所以两个位置都应使用动词不定式。 4. — What do you think of tomorrow’s football match? — It’s difficult for us to win the match....

    英语词汇固定搭配.doc

    - 宁愿某人做某事,例如:I prefer you to come early rather than late. 28. request sb. to do sth. - 要求某人做某事,例如:The client requested a meeting to discuss the project. 29. remind sb. to do sth...

    九年级英语上册重点短语默写卷精选.doc

    8. 更愿意做…而不愿意做…:prefer to do…rather than do… 9. 从现在起:from now on 10. 使某人做某事:make sb. do sth. 11. 几个:several 12. 打开、关闭:open / close 13. 由…制成(看得见原料):be made ...

    2013年中考英语 单选题专项练习(第1集)

    7. 题目考察固定搭配:prefer to do sth. rather than do sth. 意为“宁愿做…而不愿做…”,所以B. to stay 是正确答案。 8. 题目考察动词短语的搭配:borrow 意为“借入”,lend 意为“借出”,所以A. borrow, ...

    2015秋九年级英语上册Unit5ArtworldWelcometotheunit导学案无答案新版牛津版

    - 用法包括:prefer A to B(比起B更喜欢A),prefer doing A to doing B,以及prefer that sb. (should) do sth.。 - 造句示例:I prefer reading books to watching TV. 6. **课堂活动**: - 【演练展示】部分...

    山东省龙口市诸由观镇诸由中学九年级英语全册《Unit 4 I like music that I can dance to》练习

    - 更喜欢做:prefer to do - 他最著名的一首曲子:his most famous piece - 中国民族音乐:Chinese folk music - 感觉到了强烈的伤痛:feel a strong pain - 如此… 以至于:so...that... - 查阅;查询:look ...

Global site tag (gtag.js) - Google Analytics