aspose file tools*
The moose likes Beginning Java and the fly likes Quary about Setter Methord Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Quary about Setter Methord" Watch "Quary about Setter Methord" New topic
Author

Quary about Setter Methord

divya sharma
Ranch Hand

Joined: Jan 25, 2007
Posts: 87
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


Divya
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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 ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9052
    
  12


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 ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Wow, Marilyn and I are really on the same page today.
divya sharma
Ranch Hand

Joined: Jan 25, 2007
Posts: 87
Thanks for your help
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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!


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Quary about Setter Methord