Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fold or hide setters and getters in Eclipse?

Tags:

java

eclipse

The problem is that there're too much setters and getters messing up the source code editor.

I have to scroll up and down and distinguish where are the demarcation of the business methods.

Is there a plugin that I can hide or fold setters and getters?

I know there're some libraries can eliminate setters and getters by using annotations or AOP techniques, but this is not allowed in my project.

like image 636
Sawyer Avatar asked Aug 12 '10 07:08

Sawyer


People also ask

Can getters and setters be private?

The reason for declaring the getters and setters private is to make the corresponding part of the object's abstract state (i.e. the values) private. That's largely independent of the decision to use getters and setters or not to hide the implementation types, prevent direct access, etc.

How do you avoid getters and setters?

Thus: you avoid getters and setters by thinking in terms of behavior, not in terms of state. Getters/setters manipulate state, from the "outside" (by doing avail = purse.

Are getters and setters always public?

In general, they should be public. If they are private they can only be called from within your class and, since you already have access to the private variables within your class, are redundant. The point of them is to allow access to these variables to other, outside, objects.


2 Answers

Vote: https://bugs.eclipse.org/bugs/show_bug.cgi?id=69486

like image 198
Adam Rabung Avatar answered Sep 19 '22 18:09

Adam Rabung


Use Ctrl+O to navigate

Create section that separate specific part of code (like Bozho suggested).

Instead of scrolling the code You can use the outline view.

While You are working with Eclipse the mouse is not really needed.

like image 23
Damian Leszczyński - Vash Avatar answered Sep 21 '22 18:09

Damian Leszczyński - Vash