Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring and DesignPattern #78

Open
wants to merge 67 commits into
base: master
Choose a base branch
from

Conversation

hj0202
Copy link

@hj0202 hj0202 commented May 25, 2021

We refactored your project for reusability and understandability.
For more details, please check with commit.

Thanks.

hj0202 and others added 30 commits May 18, 2021 10:10
- Refactoring Part: hiddenPairInRow(), hiddenPairInColumn(), hiddenPairInSection() in QQWing.java

- Refactoring Operation: Extract Method

- Refactoring Reason: To make the code simpler and shorter by reduce duplicate code
rename ID to id to match the regular expression '^[a-z][a-zA-Z0-9]*$'
extract field("The string must be ", " characters long.")
extract method(parseValues)
merge if statements and extract variable
extract method(parse), corrected a typo
corrected typos
rename UnDo to unDo and ReDo to redo to match the regular expression '^[a-z][a-zA-Z0-9]*$'
the result of renaming to match the regular expression '^[a-z][a-zA-Z0-9]*$'
rename to match the regular expression '^[a-z][a-zA-Z0-9]*$'
merge if statements, extract method(updateNotes)
rename(overlapping level), extract method to reduce complexity
- Refactoring Part: generatePuzzleSymmetry() in QQWing.java

- Refactoring Operation: Extract Method

- Refactoring Reason: To make the code simpler and shorter by reduce duplicate code
Refactoring with extract method on GameActivity.java, LoadGameActivity.java, MainActivity.java, SettingsActivity.java, StatsActivity.java because of duplicated codes.
Refactoring with extract method on CreateSudokuActivity.java because of long method.
And I rewrited conditional statement depending on the refactoring.
Create class about file input/output because there are duplicate codes in many classes. FileInputOuput Class has two field and two function.
Extract Method and Using other class's functions to remove duplicate code about file Input/Ouput

Extract Constant "SAVES_CHANGED" refer to SonarLint

Extract Method "fillGic" "removeGic" to reduce complexity
Rename from "puzzle" to "level" because function return value means puzzle

Extract variable "gameTypeLocal" to clean code

Rename from "errorList" to "errorListLocal" to conflict with global variable

Combine if statment and extract variable for understandability

Extract constant "LAST_GAME_ID" refer to SonarLint

Extract variable "day" "month" "year" for understandability

Rename from "c" to "cell" to express meaning well
Extract Method and Using other class's method about file Input/Output to remove duplicate code
Extract Method and Using other class's method about file Input/Ouput to remove duplicate code

Remove not using variable

Extract method "getHighscoreInfoContainer" to remove duplicate code and this method overoaded.
- Refactoring Part: colBoxReduction(), rowBoxReduction() in QQWing.java

- Refactoring Operation: Extract Method

- Refactoring Reason: By extracting long method, it becomes to understand and maintain it.
- Refactoring Part: QQWing.java, QQWingController.java

- Refactoring Operation: Remove Dead Code

- Refactoring Reason: To reduce code size
Fixed an error that occurred in doSomething() and getPosition()
use singleton design pattern about GameController.java
SolverTest.java
GameControllerTest.java
CreateSudokuActivity.java
GameActivity.java
to increase memory / performance efficiency
- target class: CreateSudokuActivity.java
- design pattern: MVP(google architecture)
Apply MVP to the target class to separate UI and business logic. It makes it easy to test UI code.
Apply the template method pattern
for CreateSudokuSpecialButtonLayout.java and SudokuSpecialButtonLayout.java
to avoid duplicate code and increase reusability.
@hj0202
Copy link
Author

hj0202 commented Jun 5, 2021

I'll let you know when I'm done. Thank you

fabbitox and others added 26 commits June 5, 2021 20:22
Input: checkUri valid inputUri -> (inputSudoku, errorMessage)
Expected:
  inputSudoku != null
Input: checkUri invalid inputUri -> (inputSudoku, errorMessage)
Expected:
  inputSudoku == null
Input: isValidInputSudoku valid sudoku
Expected:
  return true
Input: isValidInputSudoku invalid size sudoku
Expected:
  return false
Input: isValidInputSudoku unsolvable sudoku
Expected:
  return false
nput: checkInputError (col, row, value) -> update errorList
Expected:
  valid errorList
…n QQWing class

Purpose: When putting a puzzle with single solution in QQWing class, test hasUniqueSolution().
Input: Input puzzle with single solution.
Expected: hasUniqueSolution() outputs True.
…s in QQWing class

Purpose: When putting a puzzle with multiple solutions in QQWing class, test hasUniqueSolution().
Input: Input puzzle with multiple solutions.
Expected: hasUniqueSolution() outputs False.
…QQWing class

Purpose: When putting a puzzle with none solution in QQWing class, test hasUniqueSolution().
Input: Input puzzle with none solution.
Expected: hasUniqueSolution() outputs False.
…ter than GameType

Purpose: When putting a puzzle with the solution shorter than GameType in QQWing class, test whether an exception is raised in hasUniqueSolution().
Input: Input puzzle with the solution shorter than GameType.
Expected: ArrayIndexOutOfBoundsException is raised.
…er than GameType

Purpose: When putting a puzzle with the solution longer than GameType in QQWing class, test hasUniqueSolution().
Input: Input puzzle with the solution longer than GameType.
Expected: hasUniqueSolution() outputs False.
Purpose: When putting null puzzle in QQWing Class, test hasUniqueSolution().
Input: Input null puzzle.
Expected: hasUniqueSolution() outputs False.
Make DailySudokuTest.java for DailySudoku Unit Test

- setHintsUsed : check setting HintsUsed variable

- setTimeNeeded : check setting TimeNeeded variable

- getOrderingDataID : check today OrderingDataID value
Create HighscoreInfoContainer.java for HighscoreInfoContainer Unit Test

- add : check adding gameController
- incHints : check increasing hints
- incTime : check increasing time
- setInfosFromFile : check setting highScoreInfoConatiner Object from file
Purpose: Test getDifficulty when GameDifficulty is Easy.
Input: Input puzzle whose GameDifficulty is Easy.
Expected: GameDifficulty.Easy
Purpose: Test getDifficulty when GameDifficulty is Moderate.
Input: Input puzzle whose GameDifficulty is Moderate.
Expected: GameDifficulty.Moderate
Purpose: Test getDifficulty when GameDifficulty is Hard.
Input: Input puzzle whose GameDifficulty is Hard.
Expected: GameDifficulty.Hard
Purpose: Test getDifficulty when GameDifficulty is Challenge.
Input: Input puzzle whose GameDifficulty is Challenge.
Expected: GameDifficulty.Challenge
Purpose: Test getDifficulty when puzzle is none-solution.
Input: Input puzzle whose solution is none.
Expected: GameDifficulty.Unspecified

I think that output is Unspecified when input is invalid.
But, this function outputs Challenge.
Merge test cases of fabbitox
@hj0202
Copy link
Author

hj0202 commented Jun 10, 2021

Refactored the project for reusability and understandability.
And I added a test case to find the error.

I'm done, so please review my pull request and check commits for more details.

Thanks.

@Kamuno
Copy link
Member

Kamuno commented Jun 10, 2021

Okay. This might take a while 😅
Thank you very much for your contribution 😄

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

Successfully merging this pull request may close these issues.

5 participants