开发者

Any tool can help refactor field into get/set pairs of method [closed]

Closed. This question does not meet Stack 开发者_JAVA百科Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 8 years ago.

Improve this question

Wondering if there is tool to assist this kind of refactoring.


Eclipse is an awesome IDE!

Any tool can help refactor field into get/set pairs of method [closed]

... or...

Any tool can help refactor field into get/set pairs of method [closed]


In Netbeans...

Any tool can help refactor field into get/set pairs of method [closed]


Eclipse has the functionality of generate getters and setters.

Source > Generate setters and getters

Source: Generate Getters and Setters


eclipse provides this. You can use my plugin as well : https://stackoverflow.com/questions/2733311/copy-field-and-methods/2734647#2734647.


It's a standard feature of the eclipse IDE (and of other IDEs too, I suppose).

Shortcut: ALT+s -> r shows the getter/setter dialog (if a class with class members was selected)

BTW - autogenerating getter/setter stubs for class members is not a refactoring.


Code refactoring is "a disciplined way to restructure code", undertaken in order to improve some of the nonfunctional attributes of the software. (wikipedia)

Autogenerating those stubs does not restructure the (existing) code. It automatically adds method implementations. And, if we look at eclipse, we don't find the according action in the list of refactorings (additional hint).

Further Reading: Self Encapsulate Field


Depending on what IDE you use, this is a standard feature provided. For instance, in Netbeans - right click on your java class and choose Refactor -> Encapsulate Fields. You can additionally select the accessors visibility, order of appearance and insert point.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜