Skip to content

Conversation

@JengYoung
Copy link
Collaborator

@JengYoung JengYoung commented Nov 29, 2022

📄 설명

양방향 연결리스트를 구현했어요!
간단하게 구현을 했으며, 주어진 테스트케이스는 모두 만족했습니다!

체크리스트들은 각각 해당되는 메서드마다 주석으로 달았어요. 참고하시면서 검토해주세요!

엣지 케이스 제보는 언제든지 환영!

완벽한 코드가 아니라 좀 많이 걱정이 되네요 😖
일단 테스트 코드들을 짜봤어요.
이는 JavaScript-DeepDive/JavaScript/07주차/assignment/재영/test.js에서 확인이 가능한데요!

테스트 코드도 가능하지만, 스크립트로도 테스트가 가능해요.
또한, 여러분이 쉽게 테스트할 수 있도록 테스트 관련 함수들을 test.js에 구현해놓았답니다.
시작 방법에 대해서는 리드미에 자세히 작성되어 있으니, 이는 리드미를 참조해주세요!

리팩토링도 언제든지 환영!

제 코드 많이 더러워요 😭
리팩토링할 만한 요소들을 알려주시면 감사드립니다 (_ _)

추운 겨울인데, 다들 화이팅해보자구요! 🥰 화이팅!!

🔗 관련 이슈

⚠️ closes #이슈 번호의 형태로 입력해주세요! PR을 머지하면 자동으로 이슈가 닫혀 관리가 쉬워집니다 😉

👀 논의해 볼 사항

많은 기능들을 탑재하기는 했는데, 뭔가 찝찝하네요!
더 구현할 만한 무언가가 있을까요? 구현할 만한 추가 기능들을 알려주세요! 언제든지 환영입니다 :)

🔑 참고할 만한 소스

예시) 이 문제를 해결하면서 이러한 링크들을 참고했는데, 참고하시길 바랍니다! <링크>

@JengYoung JengYoung added the ✅ Assignment 과제 제출 label Nov 29, 2022
@JengYoung JengYoung self-assigned this Nov 29, 2022
@JengYoung JengYoung linked an issue Nov 29, 2022 that may be closed by this pull request
5 tasks
@himyne
Copy link
Collaborator

himyne commented Nov 30, 2022

저도 지금 구현중이라 PR하고 바로 코드리뷰 하겠습니다!
좋은 과제 감사해요 .. 🙇🏻‍♀️

Copy link
Collaborator

@himyne himyne left a comment

Choose a reason for hiding this comment

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

사실 코드를 열심히 봤는데 아직 구현해주신 양방향 연결리스트의 로직이 이해가 잘 안되어서 리뷰를 제대로 하지는 못했어요 ㅠㅠ 테스트 코드 쪽에 남겨 놓은 답변을 받으면 조금 이해가 될 것 같습니다..!

Copy link
Collaborator

Choose a reason for hiding this comment

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

constructor 인자로 val을 넣어준 이유가 궁금합니다!🙋🏻‍♀️ 테스트 코드에서 보면 insert로 값을 추가하는 것 같은데 val 값을 인자로 넘겨주어 인스턴스를 생성하는 경우도 고려하신건가요??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

네 맞습니다 :)
사용자가 처음부터 초기값을 넣어줄 수도 있고, 넣지 않을 수도 있다고 생각했어요.
유동적으로 입맛에 맞게 쓸 수 있도록 했다고 보시면 될 것 같아요 :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

접근자 getter를 사용하신 이유가 궁금합니다! doubleLinkedList.node를 해주어도 node의 값을 알 수 있지 않을까요??

Copy link
Collaborator Author

@JengYoung JengYoung Dec 7, 2022

Choose a reason for hiding this comment

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

setter을 지정해주지 않았으므로 바깥의 로직이 클래스 내부의 상태를 조작할 수 없도록 안전하게 관리할 수 있기 때문입니다.
혹여나 바깥의 사용자가 로직을 실수로 변경하더라도, 안전하게 노드의 데이터를 보존할 수 있기 때문에 getter가 바람직하다고 생각해요!

아래는 도움이 되는 예시입니다.

class A {
    constructor() { this.node = 1 }
    get Node() {
        return this.Node
    }
}

const a = new A();
a.node = 3;
console.log(a.node) // 3

a.Node = 5;
console.log(a.node) // 3 ; not updated

Copy link
Collaborator

Choose a reason for hiding this comment

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

제가 양방향 연결리스트를 잘못 이해한 것인지 모르겠는데 이 부분이 잘 이해가 안돼서요..! 마지막을 삭제하면 마지막이 왜 첫번째 머리 노드가 되나요??

Copy link
Collaborator Author

@JengYoung JengYoung Dec 7, 2022

Choose a reason for hiding this comment

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

아, 저는 양방향 원형 연결 리스트(Circularly Doubly Linked List)를 만들었어요!
언젠가 캐러셀에 쓰겠다고 마음을 먹어서, 마지막 것이 나오면 - 첫 번째 것이 나오도록 만들기는 했는데, 순수 양방향 연결 리스트에 꼭 필요한 기능은 아니었다고 생각이 되네요 😖

Copy link
Collaborator Author

@JengYoung JengYoung Dec 7, 2022

Choose a reason for hiding this comment

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

제 코드가 헷갈리게 한 것 같은데, 미네님께서 하신 것이 원래 양방향 연결 리스트가 맞다고 보시면 돼요 :)
다만 저는 제 입맛에 맞게 좀 더 사짜(?)로 순환의 속성을 추가했다고 보는 게 타당하겠네요!
한글로 설명된 글을 보자면 다음 블로그 글을 참고할 수 있겠어요.
저는 여기서 더미 노드를 headtail 둘 다 명시했다고 보면 되겠네요!

Copy link
Collaborator

Choose a reason for hiding this comment

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

아하 그렇군요! 양방향 원형 연결 리스트도 한번 공부해보고 다시 코드를 보겠습니당 😂

Copy link
Collaborator Author

@JengYoung JengYoung left a comment

Choose a reason for hiding this comment

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

추가적으로 EOL을 관리해야 함을 확인합니다 + 답변을 달았습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

네 맞습니다 :)
사용자가 처음부터 초기값을 넣어줄 수도 있고, 넣지 않을 수도 있다고 생각했어요.
유동적으로 입맛에 맞게 쓸 수 있도록 했다고 보시면 될 것 같아요 :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

EOL 지켜주세요... 😭

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

EOL 지켜주세요 😖

Copy link
Collaborator Author

@JengYoung JengYoung left a comment

Choose a reason for hiding this comment

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

해야할 리스트 추가!

Copy link
Collaborator Author

@JengYoung JengYoung Dec 7, 2022

Choose a reason for hiding this comment

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

헷갈리게 한 원흉(?)을 '양방향 원형 연결리스트'로 수정합니다.

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

Labels

✅ Assignment 과제 제출

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[✅ Assignment] 양방향 연결리스트 구현하기

3 participants