<font color=red>what is the need for getter and setter methods</font>
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sabu_vs
Posted On:   Monday, September 30, 2002 10:27 PM

Hi


Could you pls tell me what is the need for getter and setter methods?

Do these methods only used in beans and EJB?


Can I use retriveName() instead of getName() ?

Do these method are mandatory



Thanks

sabu

Re: <font color=red>what is the need for getter and setter methods</font>

Posted By:   Joe_Cheng  
Posted On:   Wednesday, October 2, 2002 07:42 AM

They are not necessary unless you are working within some type of framework that expects them (yes, this includes JavaBeans, EJB, Struts, and others...).

However, I think most people would agree it is a very good idea to follow these conventions. Some of the smarter IDE's will automatically generate get/set methods for you, and recognize that get/set methods are related. Furthermore, if at some point you find yourself introspecting (say, for logging or debug purposes) you'll be able to leverage tools like Jakarta's BeanUtil.

Re: <font color=red>what is the need for getter and setter methods</font>

Posted By:   eimi_nos  
Posted On:   Monday, September 30, 2002 11:09 PM

I think getX method or setX method is standard in Java, though there seem to be some debates. In the class java.util.Calendar, for example, those methods have vital positions.


You can read some related discussions here.

Re: <font color=red>what is the need for getter and setter methods</font>

Posted By:   eimi_nos  
Posted On:   Monday, September 30, 2002 11:07 PM

I think getX method or setX method is standard in Java, though there seem to be some debates. In the class java.util.Calendar, for example, those methods have vital positions.


You can read some related discussions here.
http://forum.java.sun.com/thread.jsp?forum=54&thread=289105
About | Sitemap | Contact