-
Notifications
You must be signed in to change notification settings - Fork 11
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
dsa-week4-assignment 윤영서 #1
Open
YeongseoYoon
wants to merge
5
commits into
CodeSoom:main
Choose a base branch
from
YeongseoYoon:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+359
−115
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d3ff65b
solution: problem-1
YeongseoYoon 547beaf
solution: problem-2
YeongseoYoon 5948cfb
solution: problem-3
YeongseoYoon db6cada
solution: problem-5/SeperateChainingHashTable
YeongseoYoon d210b9b
solution: problem-5/LinearProbingHashTable
YeongseoYoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
객체의 private속성인 키 목록과 값 목록을 접근할 수 있도록 메서드를 만들어 주셨네요.
객체 안에 있는 참조 타입을 외부로 그대로 반환하게 되면 캡슐화 원칙을 깨트릴 수 있어요. 예를들어서
이런식으로 외부에서 값을 수정할 수 있게 되는거죠. 그래서 바깥으로 무언가를 전달할 때는 항상 방어적으로 작성해야 해요.
위와 같이 배열을 반환할 때 복사해서 반환하게 되면 아무리 반환된 값을 고치더라도 내부 데이터를 건드릴 수 없게 돼요. 이와 비슷하게 흔히 사용하는 방식중에 객체를 그대로 외부에서 사용할 수 있도록 할 때가 있는데요.
사실 더 안전하게 하려면 다음과 같이 해야합니다.
그러면 외부에서 값을 변경하더라도 원본 데이터는 변경되지 않습니다.
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.
오 그냥 프로퍼티 접근를 반환하는 getter setter만 있으면 방어적일 수 있다고 생각했는데, 저렇게 반환해줘야하는지 몰랐네요 ㅎㅎㅎ 감사합니다