A convenience method is a method that exists to make the developer’s
life a little easier, or the code a little clearer, without necessarily
adding to the overall functionality of the application.

Convenience methods are often used to reduce the number of arguments
needed for a method call by using common values. 

For example, given a method that removes an item from a list, given its
index: 

/** 
 * Remove the item in the receiver indicated by the given index.
 * @return the item.
 */
Object remove(int index) {...}

you might see convenience methods added that remove the first and last
items:

Object removeFirst() {
  return remove(0);
}

or 

Object removeLast() {
  return remove(this.size-1);
}

These methods don’t really add anything to the overall functionality of
a list, however they do make life more convenient for developers and
code that uses it clearer.

-----------------------------
Mike Silverstein
SilverMark, Inc.
The Object Testing Company
www.javatesting.com
**********************************
* Makers of "Test Mentor"        *
* and "Enhanced JUnit" Java      *
* component testing tools        *
**********************************

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Richard O. Hammer
> Sent: Saturday, December 13, 2003 11:09 AM
> To: Java Users Group
> Subject: [Juglist] what is a convenience method?
> 
> 
> I keep coming across methods which are called "convenience" 
> methods in 
>   their documentation.  Gosh, I'm glad.  I mean I'd hate for a method 
> to be inconvenient.
> 
> What does this mean?
> 
> Thanks,
> Rich

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 11/27/2003
 


_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to