Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Appropriate Method name?

 
Amruta Jegarkal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15436
41
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic