ClassTrim is a framework to recommend move method refactoring using Non-dominated Sorting Genetic Algorithm-II/III (NSGA-II / NSGA-III) to minimize the number of classes that exceed predefined metric thresholds. After the algorithm produces a Pareto front of candidate refactorings, a single knee solution (the one with the best overall trade-off across objectives) is automatically selected as the recommended refactoring.
Raw experiment data doi: 10.17632/8b3fd45kp6.1
Run ClassTrim plugin on smelly-demo
- Prerequisites
- JDK 17+
- Maven 3.8+
- Configure environment
- Copy
classtrim-core/src/main/resources/config.properties.exampletoclasstrim-core/src/main/resources/config.properties. - Edit the new
config.propertiesand set values for your environment:mavenRepo: absolute path to your local Maven repositorydatasetRoot: absolute path to the datasets root folderoutputFolder: output folder for results (optional; defaultoutput)projectCacheFolder: folder for serialized project cache (optional; default.project)notifyUrl: optional webhook for notifications
-
Entry point
org.classtrim.Mainrun the move method refactoring algorithm on each project.org.classtrim.NSGAII,org.classtrim.NSGAIII, ororg.classtrim.MOEADrun it once.org.classtrim.baseline.BaselineRefactorrun baseline comparison experiment.
-
Build and test modules
- Run all modules:
mvn test - Run core only:
mvn -pl classtrim-core test - Run CLI only:
mvn -pl classtrim-cli test
- Build IntelliJ plugin
- Package plugin zip:
mvn -pl classtrim-plugin -am package - Output:
classtrim-plugin/target/classtrim-plugin-1.0-SNAPSHOT-idea-plugin.zip
This repository now includes extraction scaffolding for library-style usage:
classtrim-core/: Maven module packaging the current core code and new injectable APIs underorg.classtrim.core.*classtrim-cli/: Maven module withorg.classtrim.cli.RunNsgaiiiexample entrypoint using the extracted service APIclasstrim-plugin/: IntelliJ IDEA plugin scaffold wired to run core analysis and show notifications
New core API entrypoints:
org.classtrim.core.analyzer.ProjectAnalyzer/StandardProjectAnalyzerorg.classtrim.core.engine.RefactoringEngine/NSGAIIIRefactoringEngineorg.classtrim.core.service.ClassTrimServiceorg.classtrim.core.model.ProjectSource/BinaryPathProjectSourceorg.classtrim.core.repository.ProjectRepository(in-memory and filesystem implementations)
How I calculate metrics and some common question are in wiki.
This folder contains results from baseline tools for comparison, including:
- Runtime screenshots produced during baseline runs
- Suggested outputs generated by each baseline tool (e.g.,
*.tsvsummaries)
Typical subfolders include JDeodorant/, JMove/, HMove/ and REsolution/, each organized by project-version. These
provide reference suggestions and artifacts to compare against this project's NSGA-based refactoring outputs.
- Follow unix philosophy.
- Uses Lombok to simplify data classes (getters/setters, constructors)
- Uses Java 8
Optionalto handle nulls elegantly - Emphasizes immutability; returns unmodified collections
- Caches computed objects to improve performance
- Keeps dependencies minimal
- Automatically records experiment results and summaries (summary may be improved by using a database)
- Includes unit tests
NSGA only outputs a set of non-dominated (Pareto) solutions; ClassTrim's RefactorOutput then
selects the knee of that front as the single recommended refactoring, following
Das, I., "On characterizing the 'knee' of the Pareto curve based on Normal-Boundary Intersection", Structural Optimization 18, 107–115 (1999). doi:10.1007/BF01195985
How the knee is chosen (org.classtrim.core.util.KneeSelection):
- Compute the ideal (utopian) point — the per-objective minimum across the front.
- Find the anchor solutions — the front member minimizing each objective alone (the pay-off rows).
- Build the CHIM hyperplane (Convex Hull of Individual Minima) through the anchors.
- Pick the front point of maximum bulge — farthest from the CHIM on the side of the ideal point. This is the point where each objective trade-off is most balanced. The construction is invariant to (global) rescaling of the objectives and generalizes to any number of objectives.
Selection uses only the 3 real objectives (WMC, CBO, RFC); the NSGA-III guiding objectives are search heuristics and are intentionally excluded. Degenerate fronts whose anchors collapse to a point fall back to choosing the solution closest to the ideal point.
Output: the knee is placed first, so diff-01 / metrics-01 are the recommended refactoring, and
an explicit KNEE.csv marks its objective values. The full front is still preserved in
FUN.csv / VAR.csv.
Unit tests: KneeSelectionTest
The quality of ClassTrim's Move-Method suggestions is assessed through a blinded expert
questionnaire (full plan in human-evaluation-plan.md, results in human-eval/ and
human-eval/report.md). Executive summary:
- 5 tools compared — ours (ClassTrim) vs HMove, JDeodorant, JMove, REsolution.
- 100 suggestions (20 per tool) sampled with a fixed seed; ClassTrim is deliberately sampled at an average level (standout feature-envy cases excluded) to avoid cherry-picking.
- Blinding: suggestions are shuffled into neutral IDs
S001–S100; reviewers never see the tool, metrics, or internal bookkeeping. - 20 expert reviewers (senior Java developer personas) judge items on a fixed questionnaire (RQ1-Q5): acceptance, usefulness (1-5), diagnostic value (worth inspecting?), rejection reasons, and free-text comments.
- Each item is reviewed by exactly 2 experts (balanced 20x10 assignment) to measure inter-rater agreement / Cohen's kappa.
- Analysis: acceptance rates and Q2/Q3 means per tool, ClassTrim-vs-baseline deltas, the
"detects what not where" hypothesis (Q3 vs Q1), and cross-checks vs
output/baseline-overlap.md.

