Skip to content

댓글 작성 기능 - 커맨드 패턴 처리 개선 - #7

Merged
pingu9 merged 4 commits into
feat-dj-comments-and-replyfrom
feat-dj-comments-and-reply-v2
Oct 14, 2023
Merged

댓글 작성 기능 - 커맨드 패턴 처리 개선#7
pingu9 merged 4 commits into
feat-dj-comments-and-replyfrom
feat-dj-comments-and-reply-v2

Conversation

@pingu9

@pingu9 pingu9 commented Oct 5, 2023

Copy link
Copy Markdown
Contributor

#4
이전 PR 내용에서 나왔던 내용과 같이
인영님께서 작성해주신 커맨드 패턴 처리와 같은 방식으로 개선해보았습니다.

@cheolwon1994 cheolwon1994 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

전체적으로 깔끔하게 변한것 같아서 좋았습니다! 여기서도 2가지 부분만 고쳐지면 될 것 같아요ㅋㅋㅋ

  1. CommandExecutor의 경우 기존 경로에 위치하거나 commandExecutor 패키지 산하에 두는게 좋을 것 같습니다! Command와 CommandExectuor는 분리되어야 합니다!
  2. Service는 interface로 두고, 해당 service를 implement 하는 serviceImpl을 만들고 거기에 로직이 들어가는것이 좋아보입니다!

고생하셨어요!

Comment parentComment1 = new Comment(1L, null, new ArrayList<>(), 1L, "댓글 작성 테스트1");
Comment parentComment2 = new Comment(2L, null, new ArrayList<>(), 1L, "댓글 작성 테스트2");
Comment childComment = new Comment(3L, parentComment1, new ArrayList<>(), 2L, "대댓글 작성 테스트");
Comment nestedChildComment = new Comment(4L, childComment, new ArrayList<>(), 3L, "대대댓글 작성 테스트");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

대대댓글의 경우에도 부모id는 최상위 부모로 두고, parentComment1 > childComment > nestedChildComment는 createdAt으로 구분할 수 있지 않을까요?
이렇게 하는 이유는 다음 예시때문일 것 같아요.
parentComment1
-> childComment
-> nestedChildComment
여기서 childComment가 삭제되어도 nestedChildComment는 정상적으로 보여지기 위함인것 같아요

@pingu9 pingu9 Oct 6, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

말씀해주신대로 최상위 부모의 id를 가지고 있는 것도 이점이 있다고 생각하지만 제 생각에는 말씀하신 댓글 삭제 케이스의 경우에는 삭제 시 자신의 child를 찾아 parent_id를 업데이트해주는 과정을 통해 해결할 수 있다고 생각합니다!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

음 그렇다면 제가 말한 방법은 DB에 1회 접근이고(삭제 처리) 덕주님이 말씀하신 부분은 DB에 2회 접근(삭제 + 삭제한 id를 부모로 가지고 있는 대댓글이 있다면 업데이트)인데, DB 2회 접근을 통해 1회 보다 얻는 이점이 따로 있을까요?

@pingu9 pingu9 Oct 6, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

화면 구성에 따라 다를 것 같습니다! 댓글, 대댓글, 대대댓글을 모두 다른 층위로 보여주고 싶다면
ex)
댓글
ㄴ 대댓글
ㄴㄴ 대대댓글 1
ㄴㄴㄴ 대대대댓글1
ㄴㄴ 대대댓글 2

부모 id를 정확하게 가지고 있어야 할 것 같고(하지만 이러한 화면구성이라면 보통 중간 층위 대댓글이 삭제되도 hard-delete 한 후 parent_id를 업데이트 하지 않고 soft-delete한 후 '삭제된 댓글입니다'와 같은 방식으로 표시될 것 같네요)

원 댓글만 별도의 층위이고 해당 댓글에 해당되는 모든 대댓글을 같은 층위로 보여준다면
ex)
댓글
ㄴ 대댓글1
ㄴ 대댓글2
ㄴ 대댓글3
최상위 부모 id만 가지고 있어도 충분할 것 같습니다. 저는 전자의 이미지를 가지고 작성했기 때문에 위와 같은 방식으로 했습니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

오.. 생각하지 못했던 부분이군요ㅋㅋㅋ 이 부분은 내일 회의에서도 같이 나눠보면 좋을것 같습니다! 기획팀한테는 제가 물어볼게요!

@pingu9 pingu9 Oct 6, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

넵넵 사실 기획 없는 상태에서 그냥 코딩 스타일, 패키지 구조나 현재 테스트 작성하고 있는 방식 등만 공유하고자 적당히 로직이 있을만한 내용을 임의로 작성한 내용이라서.. ㅋㅋㅋ
요즘 웹서비스에서는 대댓글은 1 layer까지만 허용하는 경우가 많아 보이네요

@pingu9

pingu9 commented Oct 6, 2023

Copy link
Copy Markdown
Contributor Author

전체적으로 깔끔하게 변한것 같아서 좋았습니다! 여기서도 2가지 부분만 고쳐지면 될 것 같아요ㅋㅋㅋ

  1. CommandExecutor의 경우 기존 경로에 위치하거나 commandExecutor 패키지 산하에 두는게 좋을 것 같습니다! Command와 CommandExectuor는 분리되어야 합니다!
  2. Service는 interface로 두고, 해당 service를 implement 하는 serviceImpl을 만들고 거기에 로직이 들어가는것이 좋아보입니다!

고생하셨어요!

감사합니다~!
향후 정식으로 기능 개발할때는 말씀주신 내용대로 작성하는 것이 좋을 것 같네요!

@@ -19,30 +19,26 @@
@RequestMapping("/comment")
public class CommentAPiController {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
public class CommentAPiController {
public class CommentAPIController {

이것도 있었네요ㅋㅋㅋ

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

앗.. 맞네요 ㅋㅋㅋ 감사합니다~!

@pingu9
pingu9 merged commit f276bbc into feat-dj-comments-and-reply Oct 14, 2023
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