RefactoringMiner icon indicating copy to clipboard operation
RefactoringMiner copied to clipboard

Missing Encapsulate Attribute refactoring

Open pedramnoori opened this issue 2 years ago • 0 comments

Problem

Missing Encapsulate Attribute refactoring while Move Attribute refactoring happened

Commit

https://github.com/graphhopper/graphhopper/commit/7f80425b6a0af9bdfef12c8a873676e39e0a04a6

Refactorings involved

1- Extract And Move Method package toDetailsString() : String extracted from public toDetailsString() : String in class com.graphhopper.storage.GraphHopperStorage & moved to class com.graphhopper.storage.BaseGraph

2- Move Attribute private nodeCount : int from class com.graphhopper.storage.GraphHopperStorage to protected nodeCount : int from class com.graphhopper.storage.BaseGraph

Description

The replacement within the aforementioned Extract and Move Method is “nodeCount -> getNodes()”. The thing is the nodeCount attribute has been moved to the destination class (BaseGraph) and reported by RefactoringMiner. This attribute also got encapsulated in the getNodes() method within the destination class, but this is not reported by the RefactoringMiner. This is a case of Encapsulate Attribute on top of the Move Attribute Refactoring.

Also note that this change is a pure and justifiable modification. Having the Encapsulate Attribute Refactoring will allow the PurityChecker to report the Extract and Move Method refactoring as a pure case.

pedramnoori avatar May 05 '23 03:05 pedramnoori