Simberon Design Minute
 

Add Methods

You'll often design a class that contains a collection of objects. When you do, you'll usually create methods to add and remove elements from the collection. The initial temptation is to call these methods add and remove. In my opinion, this is a mistake. Just using a method called add gives you no context as to what you're adding. For example, if a company has employees and you want to add an employee, it's better to call the method addEmployee rather than just add. This way, if you later add another instance variable to manage another kind of collection, there will be no confusion when you try to add new elements.

Download