Skip to content

Conversation

@Shiv239
Copy link

@Shiv239 Shiv239 commented Mar 26, 2022

Applied Refactoring:

  1. Rename Method/Variable

  2. Extract Method

  3. Move Method/Field

  4. Pull-up Method

  5. Extract Class

  6. Rename Method

File1: MultiGaus.java
File2: EmbeddedCanvas.java

Location1: https://github.com/gavalian/groot/blob/master/src/main/java/org/jlab/groot/demo/MultiGaus.java
Location2: https://github.com/gavalian/groot/blob/master/src/main/java/org/jlab/groot/graphics/EmbeddedCanvas.java

Description: Renaming the object ‘f’ to ‘frame1’, which depicts the clear sense of the name. In addition, renaming the variable ‘w’ and ‘h’ to ‘width’ and ‘height’ respectively, which clearly sounds what, it stores as the value, where to use it in further program.

  1. Extract Method

File: H1F.java

Location: https://github.com/gavalian/groot/blob/master/src/main/java/org/jlab/groot/data/H1F.java

Description: Extracting the code and creating the ‘getH1F’ method to run it filling the color as value.

  1. Pull-up Method

To: Params.java

From: https://github.com/gavalian/groot/blob/master/src/main/java/org/jlab/groot/math/Func1D.java
From: https://github.com/gavalian/groot/blob/master/src/main/java/org/jlab/groot/math/Func2D.java

Description: Creating an interface “Params” as per the acronym of ‘Parameter’. Moving the “getNDF”, “setNDF”, “setParameters” methods from “Func1D” and “Func2D” classes.

  1. Move Method

From: H2F.java
To: Axis.java

From: https://github.com/gavalian/groot/blob/master/src/main/java/org/jlab/groot/data/H2F.java
To: https://github.com/gavalian/groot/blob/master/src/main/java/org/jlab/groot/math/Axis.java

Description: Moving three methods “isValidBins”, “getBinContent” and “scliceY” from “H2F” class to “Axis” class. The reason behind for moving is that it calls the Axis class method more than the axis class itself.

  1. Extract Class

From: SetEndandOrigin.java
To: DataLine.java

To: https://github.com/gavalian/groot/blob/master/src/main/java/org/jlab/groot/data/DataLine.java

Description: Creating class “SetEndandOrigin” to run “setOrigin” and “setEnd” methods, which is moved from “DataLine” class. However, the extracted class is further extended to “DataLine” class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant