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

[또링] 웹 기반 체스 게임 2단계 구현 #106

Merged
merged 5 commits into from
Apr 28, 2020

Conversation

jnsorn
Copy link

@jnsorn jnsorn commented Apr 27, 2020

잘 부탁드립니다 :)

Copy link

@ttkmw ttkmw left a comment

Choose a reason for hiding this comment

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

안녕하세요 또링~
지난번처럼 미션 멋지게 수행하셨네요~!
피드백을 드리려고 여러번 봤지만 딱히 피드백 드릴 게 없네요..ㅜㅜ
console관련 피드백을 하나 드렸고,
피드백보다는 제가 모르는 부분이다보니 질문 남긴 게 두개 있습니다.
고생하셨습니다~!

public class GameDao {
private static final GameDao INSTANCE = new GameDao();
private static final String TABLE_NAME = "GAME";

private GameDao() {
protected GameDao() {
Copy link

@ttkmw ttkmw Apr 27, 2020

Choose a reason for hiding this comment

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

궁금한 점이 있습니다!

  1. 제가 전체 코드를 내려받지 않고 보다보니... 접근자를 protected를 한 이유가 있을까요? GameDao를 상속하는 코드가 보이지 않는데... 생성자가 필요하다면 default 접근자가 낫지 않을까요?
  2. protected로 선언하든, default로 선언하든 이제 외부에서 GameDao를 생성할 수 있기 때문에 싱글톤 객체가 아니게 됩니다. getInstance를 두는 등, 싱글톤으로 만들려고 노력하신 게 보이는 데 싱글톤으로 만드신 이유가 있을까요?

Copy link
Author

@jnsorn jnsorn Apr 30, 2020

Choose a reason for hiding this comment

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

이 질문에 대해 좀 자세히 답변드리고 싶어 이것저것 찾아보다가 이제야 답변드려요!

우선, DAO는 여러 사용자가 공유해도 DBConnection만 공유하지 않는다면 아무런 문제가 없다고 생각해서 Singleton으로 구현했습니다! 그 때문에 기본 생성자를 Private으로 두었었습니다.

하지만 2단계에서 Spring을 이용하게 됨에 따라 DAO를 bean으로 등록해주었고, bean의 특성에 의해 기본 생성자의 접근 지정자를 변경해주었어요!

자바빈은 파라미터가 없는 디폴트 생성자를 갖고 있어야 한다. 툴이나 프레임워크에서 리플렉션을 이용해 오브젝트를 생성하기 때문에 필요하다.

저도 아직 자세히 공부가 된 상태가 아니기 때문에 내부적으로 어떻게 동작하는지는 설명드릴수가 없어서 제가 이해한 내용까지만 공유해봅니다..ㅎㅎ! 더 자세히 공부하게 된다면 다시 얘기 나눠봐도 좋을 것 같네요😊👍

Copy link

Choose a reason for hiding this comment

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

그렇군요!! 공부하신 내용 공유해주셔서 감사합니다~~

@@ -66,6 +66,8 @@ const App = function App() {
function resolver(response) {
return new Promise((resolve, reject) => {
let func;
console.log(response.status);
Copy link

Choose a reason for hiding this comment

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

의도적으로 남기신 게 아니라면, 로그를 찍는 부분은 지우는 게 좋지 않을까 싶습니다~!

Copy link
Author

Choose a reason for hiding this comment

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

헉 이 부분을 놓쳤네요!😅 해당 부분 수정하겠습니다ㅎㅎ

MvcResult mvcResult = mockMvc.perform(post("http://localhost:" + port + "/move")
.contentType(MediaType.APPLICATION_JSON)
.content(gson.toJson(moveRequestDto)))
.andDo(print())
Copy link

Choose a reason for hiding this comment

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

print하면 이것저것 콘솔에 정보들이 보여지는 게 맞나요?
맞다면 테스트 코드가 많아질수록 테스트 한 번 실행하면 많은 정보가 보이다보니 복잡할 것 같은데..
혹시 print()를 두신 이유가 있나요?

Copy link
Author

Choose a reason for hiding this comment

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

좋은 지적 감사합니다~ 임루트가 예상한 대로 출력하는 코드 맞아요😅 MockMvc를 처음 사용해봐서 이것 저것 예시를 보다보니 저도 모르게 자연스럽게 추가를 했었네요..! 딱히 필요가 없으니 해당 부분 삭제하겠습니다~

Copy link
Author

Choose a reason for hiding this comment

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

며칠 전에 위와 같이 달았었는데, Jason 코치도 제 페어(비밥)도 경험상 andDo(print())는 있는게 더 좋다고 하네요! 저는 아직 MockMvc에 대한 경험이 없기 때문에 print()의 편리성이나 중요성(?)에 대해서는 몸소 깨닫지 못했는데, 사용해보기도하고 안해보기도 하면서 직접 느껴봐야겠어요!😀

Copy link

Choose a reason for hiding this comment

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

그렇군요 저도 해봐야 느낄 수 있을 것 같네요..! 감사합니다~!

@woowahan-pjs woowahan-pjs merged commit 7cc9a9e into woowacourse:jnsorn Apr 28, 2020
gracefulBrown pushed a commit that referenced this pull request May 4, 2020
* [또링] 웹 기반 체스 게임 1단계 구현 (#52)

* feat : 코드 마이그레이션

* docs : README 작성

* refactor : 테이블 구조 변경 

- 단일 게임만 가능하던 구조에서 다중 게임이 가능하도록 수정

* refactor : 예외를 try-catch에서 exception handler로 관리

* refactor : unicode로 변환하는 기능을 service에서 분리

* fix : 적을 잡으면 DB에서 삭제하도록 수정

* refactor : 페이지 렌더링 방식 변경

* refactor : 게임 종료 시 alert를 통해 알림

* fix : í�폰이 대각선으로 움직이는 기능 수정

* refactor : autoBoxing 비용 절감

* refactor : SQLException을 SQLAccessException으로 처리

* refactor : SQLException 발생 시 SQLAccessException에 해당 에러 정보 전달

* refactor : DBConnector에서 에러 발생시 프로그램 종료

* refactor : PieceDao의 save() 반환타입 변경 및 사용하지 않는 메서드 제거

* refactor : 추상적인 메서드 이름을 구체적으로 변경

* docs : 2단계 README 작성

* refactor : Spring Application으로 변경

* refactor : exception handler를 위한 advice 생성

* test : controller 테스트 추가

* test : controller의 save, load 테스트 추가

* [또링] 웹 기반 체스 게임 2단계 구현 (#106)

* docs : 2단계 README 작성

* refactor : Spring Application으로 변경

* refactor : exception handler를 위한 advice 생성

* test : controller 테스트 추가

* test : controller의 save, load 테스트 추가

* docs : 3단계 README 작성

* feat : entity 생성

* feat : repository 생성

* feat : 3단계 Spring Data JDBC 적용

* refactor : 서비스 코드 개선

Co-authored-by: 또링 <jnsorn@gmail.com>
gracefulBrown pushed a commit that referenced this pull request May 5, 2020
* [또링] 웹 기반 체스 게임 1단계 구현 (#52)

* feat : 코드 마이그레이션

* docs : README 작성

* refactor : 테이블 구조 변경 

- 단일 게임만 가능하던 구조에서 다중 게임이 가능하도록 수정

* refactor : 예외를 try-catch에서 exception handler로 관리

* refactor : unicode로 변환하는 기능을 service에서 분리

* fix : 적을 잡으면 DB에서 삭제하도록 수정

* refactor : 페이지 렌더링 방식 변경

* refactor : 게임 종료 시 alert를 통해 알림

* fix : í�폰이 대각선으로 움직이는 기능 수정

* refactor : autoBoxing 비용 절감

* refactor : SQLException을 SQLAccessException으로 처리

* refactor : SQLException 발생 시 SQLAccessException에 해당 에러 정보 전달

* refactor : DBConnector에서 에러 발생시 프로그램 종료

* refactor : PieceDao의 save() 반환타입 변경 및 사용하지 않는 메서드 제거

* refactor : 추상적인 메서드 이름을 구체적으로 변경

* docs : 2단계 README 작성

* refactor : Spring Application으로 변경

* refactor : exception handler를 위한 advice 생성

* test : controller 테스트 추가

* test : controller의 save, load 테스트 추가

* [또링] 웹 기반 체스 게임 2단계 구현 (#106)

* docs : 2단계 README 작성

* refactor : Spring Application으로 변경

* refactor : exception handler를 위한 advice 생성

* test : controller 테스트 추가

* test : controller의 save, load 테스트 추가

* docs : 3단계 README 작성

* feat : entity 생성

* feat : repository 생성

* feat : 3단계 Spring Data JDBC 적용

* refactor : 서비스 코드 개선

* [또링] 웹 기반 체스 게임 3단계 구현 (#129)

* docs : 2단계 README 작성

* refactor : Spring Application으로 변경

* refactor : exception handler를 위한 advice 생성

* test : controller 테스트 추가

* test : controller의 save, load 테스트 추가

* docs : 3단계 README 작성

* feat : entity 생성

* feat : repository 생성

* feat : 3단계 Spring Data JDBC 적용

* refactor : 서비스 코드 개선

* docs : 4단계  README 작성

* feat : 생성된 방 목록을 보여주는 기능 구현

* fix : 게임 id와 움직일 정보를 hidden으로 저장

* refactor : 게임 목록을 보여줄 때 DB에서 게임 ID만 가져오도록 수정

* fix : 점수가 제대로 계산되도록 수정

* refactor : console.log 제거

* refactor : 메서드 이름 변경

* merge from jnsorn

* 피드백 반영

* 피드백 반영

Co-authored-by: 또링 <jnsorn@gmail.com>
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.

3 participants