Difference: JavaNotes (8 vs. 9)

Revision 903 Feb 2003 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="ProgrammingTips"
(back to ProgrammingTips)
Line: 40 to 40
  When something is an identifier, and you feel that you must append "Id" in some form to the name, use ID not Id. It's easier to type and reflects that most people call it an "eye-dee" not an "id".
Added:
>
>
When a class has a member variable that holds multiple items, don't make a setFoo(Collection foos) method, make an addFoo(Foo foo) method instead. Maintain the collection (or set or whatever) internally. The difference is that there's some type checking in the second approach whereas the first approach lets the client pass a Collection full of anything in. It's also often more convenient for the client to call add() a few times rather than create their collection, fill it, and then set() it. If they want to look at it you can return either a collection/set/list (some interface) or you can return an iterator of some sort.
 

Misc

Here's a cute hack to enable token substitution in java property files: http://www.sys-con.com/java/source.cfm?id=1228

View topic | History: r36 < r35 < r34 < r33 | More topic actions...
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback