• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Quary about Setter Methord

 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am working on a project in Java my knowledge in java is beginner level.

in my project in EmployeeProfileDTO.java they created setter methord as :
-----------------------------------------------------------------------
public void setEmployeeStartDate(String string) {
employeeStartDate = string;
}
-------------------------------------------------------------------------
My question is why they define String,String why not String employeeStartDate!!!

Please help

Thanks
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by divya sharma:
... My question is why they define String,String why not String employeeStartDate!!!...

That's an excellent question. My preference is to use the same variable name in a setter, along with "this" to set the variable...

In any case, "string" is a terrible name for a variable!
[ September 05, 2007: Message edited by: marc weber ]
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Maybe they don't understand how to use "this". I think that "string" is not very descriptive, and you are asking an excellent question.


would be better if employeeStartDate is a member variable. If employeeStartDate is a local variable, (I think that is doubtful since this is a setter), you could use something like

[ September 05, 2007: Message edited by: Marilyn de Queiroz ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, Marilyn and I are really on the same page today.
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eclipse generates names like those when you ask it to generate the unimplemented methods or create a method. Kudos for being offended and wanting to improve them!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic