Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » getter and setter methods are private?
getter and setter methods are private? [message #132927] Wed, 08 November 2006 11:12 Go to next message
Eclipse UserFriend
Originally posted by: m.fernau.cps-net.de

Hello everybody!

Sorry, I'm totally new to VE and want to give it a try. A simple question
for me is how I can make the generated getter and setter-Methods be public?
VE generates them all as private methods..
Maybe I misunderstanding something, but haven't I to use the Visual-Class
from another Class and fill it with "life" like add entries to a list which
is inside this Panel? If the getter and setter-Methods are all private I
can't do this.

Thanks for any help!

Regards,
Martin
Re: getter and setter methods are private? [message #132942 is a reply to message #132927] Wed, 08 November 2006 17:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

They are private because

(1) There is no setter. The getter's are lazy create methods.
(2) The children are internals and should not normally be exposed to
the outside.
(3) If we used public methods, there could be interactions with super
classes that are using the same name for a method. By being private
we can guarantee there would be no conflicts.
(4) For your particular case, exposing the list itself is not what you
would want to do, instead you would create a public method that
would add an entry to the list for you. That would be the safer
way of doing it. You can then make appropriate checks like does
it already exist, or do I need to wrapper it first before I put
it into the model.
(4) If you really want something to be public, then create a new
public get method that returns the value by calling the private
method. However, don't create a setter. That would cause problems,
unless you were very careful to link the new child into the
picture, and unlink the old one. For example, if the child was
a visual you would need remove the old child, and add the new child.
And if there are listeners on the child you would need to remove
them from the old child and add them to the new child.

Martin Fernau wrote:
> Hello everybody!
>
> Sorry, I'm totally new to VE and want to give it a try. A simple question
> for me is how I can make the generated getter and setter-Methods be public?
> VE generates them all as private methods..
> Maybe I misunderstanding something, but haven't I to use the Visual-Class
> from another Class and fill it with "life" like add entries to a list which
> is inside this Panel? If the getter and setter-Methods are all private I
> can't do this.
>
> Thanks for any help!
>
> Regards,
> Martin

--
Thanks,
Rich Kulp
Re: getter and setter methods are private? [message #133005 is a reply to message #132942] Thu, 09 November 2006 08:35 Go to previous message
Eclipse UserFriend
Originally posted by: m.fernau.cps-net.de

Thanks for the explanation and sorry for my newbee-question!

I think I now understand the way how VE works. I will create public methods
which set the preferred value to the field (ie: setting a text to a label).

Regards,
Martin

Rich Kulp wrote:

> They are private because
>
> (1) There is no setter. The getter's are lazy create methods.
> (2) The children are internals and should not normally be exposed to
> the outside.
> (3) If we used public methods, there could be interactions with super
> classes that are using the same name for a method. By being private
> we can guarantee there would be no conflicts.
> (4) For your particular case, exposing the list itself is not what you
> would want to do, instead you would create a public method that
> would add an entry to the list for you. That would be the safer
> way of doing it. You can then make appropriate checks like does
> it already exist, or do I need to wrapper it first before I put
> it into the model.
> (4) If you really want something to be public, then create a new
> public get method that returns the value by calling the private
> method. However, don't create a setter. That would cause problems,
> unless you were very careful to link the new child into the
> picture, and unlink the old one. For example, if the child was
> a visual you would need remove the old child, and add the new child.
> And if there are listeners on the child you would need to remove
> them from the old child and add them to the new child.
Re: getter and setter methods are private? [message #614765 is a reply to message #132927] Wed, 08 November 2006 17:35 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

They are private because

(1) There is no setter. The getter's are lazy create methods.
(2) The children are internals and should not normally be exposed to
the outside.
(3) If we used public methods, there could be interactions with super
classes that are using the same name for a method. By being private
we can guarantee there would be no conflicts.
(4) For your particular case, exposing the list itself is not what you
would want to do, instead you would create a public method that
would add an entry to the list for you. That would be the safer
way of doing it. You can then make appropriate checks like does
it already exist, or do I need to wrapper it first before I put
it into the model.
(4) If you really want something to be public, then create a new
public get method that returns the value by calling the private
method. However, don't create a setter. That would cause problems,
unless you were very careful to link the new child into the
picture, and unlink the old one. For example, if the child was
a visual you would need remove the old child, and add the new child.
And if there are listeners on the child you would need to remove
them from the old child and add them to the new child.

Martin Fernau wrote:
> Hello everybody!
>
> Sorry, I'm totally new to VE and want to give it a try. A simple question
> for me is how I can make the generated getter and setter-Methods be public?
> VE generates them all as private methods..
> Maybe I misunderstanding something, but haven't I to use the Visual-Class
> from another Class and fill it with "life" like add entries to a list which
> is inside this Panel? If the getter and setter-Methods are all private I
> can't do this.
>
> Thanks for any help!
>
> Regards,
> Martin

--
Thanks,
Rich Kulp
Re: getter and setter methods are private? [message #614770 is a reply to message #132942] Thu, 09 November 2006 08:35 Go to previous message
Martin Fernau is currently offline Martin FernauFriend
Messages: 13
Registered: July 2009
Junior Member
Thanks for the explanation and sorry for my newbee-question!

I think I now understand the way how VE works. I will create public methods
which set the preferred value to the field (ie: setting a text to a label).

Regards,
Martin

Rich Kulp wrote:

> They are private because
>
> (1) There is no setter. The getter's are lazy create methods.
> (2) The children are internals and should not normally be exposed to
> the outside.
> (3) If we used public methods, there could be interactions with super
> classes that are using the same name for a method. By being private
> we can guarantee there would be no conflicts.
> (4) For your particular case, exposing the list itself is not what you
> would want to do, instead you would create a public method that
> would add an entry to the list for you. That would be the safer
> way of doing it. You can then make appropriate checks like does
> it already exist, or do I need to wrapper it first before I put
> it into the model.
> (4) If you really want something to be public, then create a new
> public get method that returns the value by calling the private
> method. However, don't create a setter. That would cause problems,
> unless you were very careful to link the new child into the
> picture, and unlink the old one. For example, if the child was
> a visual you would need remove the old child, and add the new child.
> And if there are listeners on the child you would need to remove
> them from the old child and add them to the new child.
Previous Topic:Linking classes across projects
Next Topic:Linking classes across projects
Goto Forum:
  


Current Time: Fri Apr 19 12:44:17 GMT 2024

Powered by FUDForum. Page generated in 0.01935 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top