Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Recommenders/CleanCodeMethodSorter"

(Initial description)
 
m (typos)
Line 22: Line 22:
 
=== Processing of individual Java-classes  ===
 
=== Processing of individual Java-classes  ===
  
When a Java-class is opened in the Java Editor, the source menu should be visible in the main menu bar. The plugin augments the import-group in the source menu at with a command named "Sort methods…" , triggering this command lets the Clean Code Method Sorter sort the methods in this class. Per default, the command is bound to the keybinding "Option-S" (Mac) or "alt-S" (other platforms). User-defined keybindings are possible: Just search for the command "Sort methods…" in the "Clean Code" kategory in the keys-preferences-menu.  
+
When a Java-class is opened in the Java Editor, the source menu should be visible in the main menu bar. The plugin augments the import-group in the source menu with a command labeled "Sort methods…". Triggering this command lets the Clean Code Method Sorter sort the methods in this class.
  
[[Image:SourceMenu.jpg]]  
+
 
 +
 
 +
Per default, the command is bound to the keybinding "Option-S" (Mac) or "alt-S" (other platforms). User-defined keybindings are possible: Search for the command "Sort methods…" in the "Clean Code"-category in the keys-preferences-menu.
 +
 
 +
[[Image:SourceMenu.jpg]]
  
 
=== Processing of multiple Java-classes  ===
 
=== Processing of multiple Java-classes  ===

Revision as of 12:12, 19 August 2011

Plugin-Description

The Clean Code Method Sorter is an plugin for the Eclipse Platform. It provides techniques to sort methods in Java-classes aiming to increase the readability of the source code. Methods are reordered following the news-paper-metaphor conceived by Robert C. Martin in his book "Clean Code": A class should be readable like a newspaper, with the most important methods being at the beginning of the class, followed by methods which are invoked later in the execution flow.

Additional possibilities of method organization are planned for further builds:

  • Clustering of getters and setters
  • Clustering of overloaded methods

Installation Instructions

You can download and install the plugin using the update-site.

Please report any encountered bugs here (suggestions are also welcome).

Currently BETA-stadium: Features and description are subject to change. No issues reported, (but) use it at your own risk.

User-Interface

The plugin mainly provides a "Sort Methods"-Operation which can be triggered from different Points.

Processing of individual Java-classes

When a Java-class is opened in the Java Editor, the source menu should be visible in the main menu bar. The plugin augments the import-group in the source menu with a command labeled "Sort methods…". Triggering this command lets the Clean Code Method Sorter sort the methods in this class.


Per default, the command is bound to the keybinding "Option-S" (Mac) or "alt-S" (other platforms). User-defined keybindings are possible: Search for the command "Sort methods…" in the "Clean Code"-category in the keys-preferences-menu.

SourceMenu.jpg

Processing of multiple Java-classes

When selecting Java-specific content in the Package Explorer, and activating the Pop-Up-menu, the Source-submenu is visible. The plugin augments the import-group in this menu with command named "Sort methods…" which will sort all methods in selected objects and their children upon triggering. "Sort methods…" can be called on any selection of Java-projects, source folders, packages and compilation units (Java-files). After successful sorting, a message will appear showing the number of processed classes.

In the beta-phase an additional command "Shuffle methods randomly…" may be available which shuffles methods randomly to enable easier evaluation of the method sorter.


PulldownMenu.jpg

Preferences

This section will be expanded in the following builds.

Currenty, following preferences are provided:

Invocation ordering strategy in method bodies
  • Breadth-first: Ordering is following a breadth-first-search approach in the invocation graph.
  • Depth-first: Ordering is following a depth-first-search approach in the invocation graph.
Priorize access levels

When activated, methods are clustered according to their access level before being sorted by invocation order.

Back to the top