-
Notifications
You must be signed in to change notification settings - Fork 0
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
[BE-REFACTOR] 포켓몬 정보 MongoDB 리팩토링 #336
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
종이 고생하셨습니다!! 리뷰 남겨놨어요 😊 화이팅!!!
그리고 테스트 코드가 없는데 정말 단순한 로직이 아니라면 테스트 코드가 필요할 것 같아요~!
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/dto/MoveResponse.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/config/MongoConfiguration.java
Outdated
Show resolved
Hide resolved
.../pokerogue/src/main/java/com/pokerogue/helper/pokemon/config/PokemonDatabaseInitializer.java
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/data/EvolutionItem.java
Show resolved
Hide resolved
@Override | ||
public EvolutionItem convert(String id) { | ||
return EvolutionItem.findById(id) | ||
.orElseThrow(() -> new GlobalCustomException(ErrorMessage.EVOLUTION_NOT_FOUND)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not found 에러보다 convert 관련 에러가 더 명확하지 않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거 저희끼리 정해야겠네요 🤔 오늘 정하면 어떤데 (12시 지났으니까 오늘로...^^)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋아유
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금 코드에서 에러는 notfound + 500이 괜찮아 보여요.
convert하다가 문제가 생긴 것도 맞지만 orElseThrow안에는 NotFound가 적절해보여요.
try-catch로 convert 관련 에러로 추상화시키는게 나을까요?🍀
backend/pokerogue/src/main/java/com/pokerogue/helper/global/exception/ErrorMessage.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/PokemonService.java
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/PokemonService.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/PokemonService.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/PokemonService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요 종이!
코드 잘 확인했고 고생하셨습니다!
전반적으로 리팩토링을 하기로 했기 때문에 그런 부분들과 테스트 보강을 위주로 작성했어요!
확인해주세요!
backend/pokerogue/src/main/java/com/pokerogue/helper/biome/service/BiomeService.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/config/MongoConfiguration.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/config/ReadTypeConverter.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/data/FormChange.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/data/Pokemon.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/PokemonService.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/PokemonService.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/PokemonService.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/PokemonService.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/PokemonService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
폴라랑 미아가 열심히 달아줘서 간단한 것만 달았기에 approve합니다!
구현 수고하셨습니다! 👍
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/config/MongoConfiguration.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/config/MongoConfiguration.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/config/ReadItemConverter.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/data/Evolution.java
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/PokemonService.java
Outdated
Show resolved
Hide resolved
리뷰 반영 완료했습니다
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
개행🐶 이랑 접근제어자만 한번 봐주세요! 😋
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/config/ImageUrl.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/data/PokemonValidator.java
Outdated
Show resolved
Hide resolved
|
||
static void validatePokemonSize(int pokemonCount) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default
고민 해봅시다 🤔
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/BufferedQueue.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/EvolutionContext.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/test/java/com/pokerogue/helper/pokemon/data/FakeEvolution.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/test/java/com/pokerogue/helper/pokemon/data/FakePokemon.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/test/java/com/pokerogue/helper/pokemon/service/BufferedQueueTest.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/test/java/com/pokerogue/helper/pokemon/service/EvolutionContextTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
종이!!! 서비스 코드가 정말 깔끔해졌고 데이터 테스트도 완벽하네요 😊👍 저번 리뷰들은 다 resolve 처리했습니다! 추가 리뷰 몇 개 달아놨어요 😉
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/EvolutionContext.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/EvolutionService.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/EvolutionContext.java
Outdated
Show resolved
Hide resolved
) | ||
.flatMap(stream -> stream) | ||
.findFirst() | ||
.orElseThrow(() -> new GlobalCustomException(ErrorMessage.POKEMON_NOT_FOUND)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public Evolution getEvolutionOf(String pokemonId) {
return evolutions.stream()
.filter(evolution -> evolution.getTo().equals(pokemonId) || evolution.getFrom().equals(pokemonId))
.findFirst()
.orElseThrow(() -> new GlobalCustomException(ErrorMessage.POKEMON_NOT_FOUND));
}
이렇게 스트림 한 번 쓰는게 더 효율적일 것 같아요!
++) getter 대신 메소드 만드는 것도 제안해봅니다
.filter(evolution -> evolution.hasSameTo(pokemonId) || evolution.hasSameFrom(pokemonId))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이부분은 모든 포켓몬의 getTo
를 먼저 찾은 후, getFrom
을 찾아야해서 Stream.of 연산을 사용하였습니다!
(진화 가능한 포켓몬이라면 getTo의 evolution을 가져오고, 루트 포켓몬이라면 getFrom의 evolution을 가져온다.)
제가 작성한 코드가 스트림의 순서에 의존적이고 가독성이 좋은 코드는 아닌 거 같네요!
더 좋은 방법이 있을지 고민해보겠습니다😲
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굿! 천천히 생각해봐도 좋을 것 같아요 👍
backend/pokerogue/src/main/java/com/pokerogue/helper/pokemon/service/TreeDepthCalculator.java
Outdated
Show resolved
Hide resolved
.peek(this::decreaseIndegreeCount) | ||
.filter(this::isIndegreeZero) | ||
.filter(this::isAdjacentNodeExist) | ||
.forEach(bufferedQueue::add); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍 너무 이해하기 쉽네요!!! 최고
package com.pokerogue.helper.pokemon.data; | ||
|
||
|
||
public class FakeEvolution extends Evolution { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저번에 잠깐 얘기했던 대로 Fake 객체를 일일이 만드는 것보다 Collection(여기에서는 Evolution)에 생성자 등을 추가하는게 더 좋을 것 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Evolution이 변경되면(메소드 추가 등) Fake 객체를 항상 일관되게 맞춰줘야 하는데 놓치기 쉬울 것 같아서요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Evolution
은 �AllArgs을 열고 Pokemon
은 빈생성자의 접근제어를 해제하고 Setter를 열었습니다.
아무래도 포켓몬은 생성자 매개변수가 너무 많아서.. Setter
를 열면 부작용이 생길까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 배틀 테스트하면서 그거 때문에 약간 고민했는데 .. 사실 우리 서비스 로직에서 실수로라도 setter를 사용할 일이 거의 없다고 보기 때문에 일단 괜찮을 것 같습니다 🤔 하지만 다같이 또 논의해봐요!
backend/pokerogue/src/test/java/com/pokerogue/helper/pokemon/PokeomonControllerTest.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/test/java/com/pokerogue/helper/pokemon/data/PokemonDataTest.java
Outdated
Show resolved
Hide resolved
backend/pokerogue/src/test/java/com/pokerogue/helper/pokemon/service/EvolutionContextTest.java
Outdated
Show resolved
Hide resolved
/noti |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨어요 종이!
미아까지 머지 이후 테스트 작성하면서 궁금하거나 리팩토링 욕심이 나는 부분들은 따로 연락드리도록 할게요!
130개의 코멘트 동안 수고하셨습니다 ㅋㅋㅋㅋ 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 !!! 머지 고고.
🍄 PR 확인 사항
PR이 다음 요구 사항을 충족하는지 확인하세요. :
현재 작업은 어떤 이슈를 해결한 것인지 설명해주세요.
기존 코드에서 변경된 점이 있다면 설명해주세요. (추가 X)
Type
은 바이옴에서 사용하고 있어서 지우지 않음MongoConfiguration
추가, 타입컨버터와 아이템 컨버터MongoConfiguration
에 추가EvolutionItem
이넘에 추가