Skip to content

step 34 로빈#19

Open
robinjoon wants to merge 45 commits intowoowacourse-6th-code-review-study:robinjoonfrom
robinjoon:step4
Open

step 34 로빈#19
robinjoon wants to merge 45 commits intowoowacourse-6th-code-review-study:robinjoonfrom
robinjoon:step4

Conversation

@robinjoon
Copy link
Copy Markdown
Member

원본 PR 참고해주세여
woowacourse#749

Copy link
Copy Markdown

@3Juhwan 3Juhwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로빈, 안녕하세요~ 망쵸입니다!
코드 잘 봤어요. JDBC, DB와 관련된 코드가 인상적이었어요 💯
덕분에 제가 학습하지 못한 부분을 학습할 수 있었어요.
레벨1 정말 고생 많았고, 레벨2도 열심히 해보아요 ✊✊

import java.util.List;
import java.util.stream.Collectors;

public class PiecesOnChessBoardDAOForMysql implements PiecesOnChessBoardDAO {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

특정 DB에 매우 종속적인 네이밍이네요! 구현체니까 괜찮은 것 같아요. 다만, 다소 길다는 느낌은 있네요!

Comment on lines +50 to +52
private record DBConnectionParameters(String url, String userName, String password) {
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

내부 클래스를 이렇게 잘 사용할 수 있네요! 사소하지만 대단하다고 느껴지네요 👍

Comment on lines +31 to +40
startTransaction(connection);
if (isSaveDataExist()) {
List<Piece> pieces = piecesOnChessBoardDAO.selectAll(connection);
Team currentTeam = turnDAO.select(connection).get();
commitTransaction(connection);
return new ChessGame(pieces, currentTeam);
}
piecesOnChessBoardDAO.deleteAll(connection);
turnDAO.delete(connection);
commitTransaction(connection);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

트랜잭션 구현 멋지네요.. 👍

Comment on lines +71 to +78
startTransaction(connection);
if (canNotSave(connection)) {
return false;
}
boolean saveAllPiecesSuccess = piecesOnChessBoardDAO.saveAll(piecesOnBoard, connection);
Team currentTeam = chessGame.currentTeam();
boolean saveTurnSuccess = turnDAO.save(currentTeam, connection);
commitTransaction(connection);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

트랜잭션을 거는 코드가 반복되는데, 개선할 방법은 없을까요? 고민해 보셨다면, 이렇게 작성한 근거가 궁금해요 💭

import java.sql.SQLException;
import java.util.List;

public class ChessPersistence {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

클래스명에 Persistence를 넣은 의도는 알 것 같은데, 개인적으로 의미가 명확하게 와닿지 않네요!

Comment on lines +28 to +33
private static class FakeConnection implements Connection {

@Override
public Statement createStatement() throws SQLException {
return null;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아직 미완성인 건가요? 🤔

import org.junit.jupiter.api.Test;

class TurnDAOForMysqlTest {
private static final String DB_URL = "jdbc:mysql://localhost:13306/chess2?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

프로덕트와 다른 DB를 사용하셨네요! 이 방법을 선택한 이유가 있을까요?

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.

2 participants