File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Appropriate Method name? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Appropriate Method name?" Watch "Appropriate Method name?" New topic

Appropriate Method name?

Amruta Jegarkal

Joined: Nov 29, 2012
Posts: 29
My method returns boolean value.....It accepts Event class object as parameter....Event is a class with property like name,type of event,dateof event,time,id with setters/getters......This method deletes event from file.txt if id in event sent is present in file.....Sends true if id is present else false.......Suggest me a appropriate name for this method as isDeleteEvent() is not appropriate as per my sir.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

I would just call it deleteEvent.

Since the method has a side effect (it changes the state of a file), I would indeed not call it isDeleteEvent, because that name suggests the method is a getter method, which should not change the state of any object or file.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Matthew Brown

Joined: Apr 06, 2010
Posts: 4543

Agree with Jesper. Either deleteEvent or removeEvent.

I tend to try and use create/delete and add/remove in pairs, so which of the two I'd choose would probably depend on what the corresponding method for adding events to the file.
I agree. Here's the link:
subject: Appropriate Method name?
It's not a secret anymore!