refactor variable visibility?

Before I file this, I wanted to know if there was a way to change, via
refactoring, the visibility of a variable. What I mean is:

protected String foo;

for some reason someone changed this variable to protected and is
accessing it from other places in the code. What I want to do is:

1- add a method called getFoo()
2- change visibility of var to private and have idea cascade the change
to the rest of the code to use getFoo() instead of direct variable
access.

Thanks
R

5 comments
Comment actions Permalink

Never used it yet, but your description is exactly what I expect from
'Encapsulate Fields...'.

Robert S. Sfeir wrote:

Before I file this, I wanted to know if there was a way to change, via
refactoring, the visibility of a variable. What I mean is:

protected String foo;

for some reason someone changed this variable to protected and is
accessing it from other places in the code. What I want to do is:

1- add a method called getFoo()
2- change visibility of var to private and have idea cascade the change
to the rest of the code to use getFoo() instead of direct variable
access.

Thanks
R


--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0
Comment actions Permalink

Robert S. Sfeir wrote:

1- add a method called getFoo()
2- change visibility of var to private and have idea cascade the change
to the rest of the code to use getFoo() instead of direct variable
access.


Refactor -> Encapsulate Fields is your friend :)

Sascha

0
Comment actions Permalink

In article <no_mail-F4F891.11204402022005@mail.intellij.net>,
"Robert S. Sfeir" <no_mail@jetbrains.com> wrote:

Before I file this, I wanted to know if there was a way to change, via
refactoring, the visibility of a variable. What I mean is:

protected String foo;

for some reason someone changed this variable to protected and is
accessing it from other places in the code. What I want to do is:

1- add a method called getFoo()
2- change visibility of var to private and have idea cascade the change
to the rest of the code to use getFoo() instead of direct variable
access.

Thanks
R


thanks guys... this is the 2nd time in a week that I can't figure out a
refactoring's name... I'm getting more retarded by the minute... watch
out :)

R

0
Comment actions Permalink

I'm getting more retarded by the minute... watch out :)


Ah, I feel the same! It must be the infrequent releases of EAP builds. After using EAP for so long, you need more and more of that... and faster...

Dark corner happy place happy place happy place...

0
Comment actions Permalink

In article <16868925.1107370961827.JavaMail.itn@is.intellij.net>,
Marcus Brito <mbrito@gmail.com> wrote:

I'm getting more retarded by the minute... watch out :)


Ah, I feel the same! It must be the infrequent releases of EAP builds. After
using EAP for so long, you need more and more of that... and faster...

Dark corner happy place happy place happy place...


well I think the infrequent releases mean we need to concentrate more on
our own stuff, which leads to using features we don't usually use :)

R

0

Please sign in to leave a comment.