-
Notifications
You must be signed in to change notification settings - Fork 41
Lecture3 - step1. 기본기능 구현 #40
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
Conversation
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.
수고하셨어요~
메서드 단위가 작은규모라 좋군요.
saveData를 옮기셔야할거 같고, 그밖에 리뷰는 남기니 수정해보세요~
| @@ -0,0 +1,27 @@ | |||
| const todo = { | |||
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.
스켈레톤 코드 잘했어요~
todo.js
Outdated
| @@ -0,0 +1,102 @@ | |||
| const saveData = { | |||
| task: [],//데이터를 축적시키는 배열 | |||
| idArrays: [] | |||
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.
task에 각각 있는 id값과 idArrays가 완전히 정확히 동기화되어야 하는 어려움이 좀 있겠네요.
잘 맞출 수만 있다면 괜찮은 방법인거 같고요.
느리지만 정확하게 하려면 idArrays를 필요할때마다 task에서 추출하는 것이죠.
todo.js
Outdated
| const todo = { | ||
| getRanNum: function () { | ||
| const ranNum = Math.floor(Math.random() * 100) | ||
| if(saveData.idArrays.indexOf(ranNum) !== -1) { |
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.
중복방지로직은 좋아요~
array 에 include와 같은 메서드는 없는지도 한번 찾아보세요~
todo.js
Outdated
| done: 0 | ||
| } | ||
| accumulatedTask.forEach(obj => { | ||
| obj['status'] === 'todo' ? statusNum.todo++ : |
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.
이건 어때요?
statusNum[obj.status]++
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.
대단하네요.....진짜 감탄했습니다.
| }, | ||
|
|
||
| add: function (objToAdd) { | ||
| const newTodo = { |
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.
새로운 객체 생성 잘했어요.
todo.js
Outdated
| @@ -0,0 +1,102 @@ | |||
| const saveData = { | |||
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.
객체는
속성과 그속성을 제어하는 행위(함수)로 구성됩니다.
todo객체에서 task는 아주 중요한 속성이죠.
따라서 별로 객체에 두지않고 당연히 todo객체안에 있고, this를 통해서 객체안의 속성을 접근해야 합니다.
지금처럼 분리하는 경우는 todo와 같은 것이 한개 이상이고, 여러객체에서 saveData를 공유하는 경우에 그렇게 할수 있습니다.
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.
친절하신 피드백과 답변 감사드립니다. 항상 크롱의 피드백은 여러번 읽으면 더 잘 이해되서 좋더라구요ㅎㅎ 감사합니다 바로 수정해서 다시 푸시하고 수정사항 달겠습니다.
…des(ranNum))으로 변경
언제나 피드백 감사드립니다. |
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.
고민스러운 리뷰를 계속 남기게 되네요.
다음스텝 넘어가면서 고민(?) 이어가면서 해보세요.
| this.task.push(newTodo) | ||
| let statusNum = this.getStatusNum(this.task) | ||
| console.log(`ID : ${newTodo.id}, ${newTodo.name} 항목이 추가되었습니다.`); | ||
| this.printStatusNum(statusNum) |
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.
바로위에서 console.log 를 호출해서 무언가 출력하고,
그 다음줄에서는 console.log로 동작하는 함수를 호출하고,
비슷한 것들이니 같이 print함수쪽으로 모아서 처리하도록 하는 것도 검토할 수 있을 듯.
| } | ||
| return taskObj | ||
| }) | ||
| const changedTask = this.task.filter(taskObj => { |
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.
map, filter의 활용법을 잘 이해한거 같네요.
그런데 이렇게 구현하다보면 가끔 중복적인 반복은 아닌가? 싶은 마음도 들긴해요.
어려운 문제에요. 앞으로 다른것도 구현하면서 적절함을 찾아나가도록 해보세요.
| @@ -0,0 +1,95 @@ | |||
| const todo = { | |||
| task: [], | |||
| idArrays: [], | |||
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.
task의 아이디와 idArrays가 sync가 잘 맞는것이라는 확신!을 할 수 있을지..
소프트웨어는 보통 같은 데이터를 이렇게 동기화하진 않아요.
두 개의 참조가 다르기때문에 어떤이유로 달라질 수 있는 셈이죠.
* Lecture3 - step1. 기본기능 구현 (#40) * 스켈레톤 코드 작성 * 수많은 에러가 담긴 todo객체의 add함수 추가(id의 값을 제대로 가지지 못함, todo객체의 getStatusNum수정 필요 * 랜덤한 id값을 못가져오는 것을 수정. checkOverlap함수를 통해서 id의 값이 같지않도록 구현 * todo.add함수기능 완벽하게 구현 * todo.update함수 완성 * id를 입력받아 할일을 제거해주는 todo.remove함수 완성, 오류가많은 todo.printTask함수 완성 * todo.printTask함수 완성, tag를 확인하는 함수 제거(printTask를 통해 각 할일들의 태그가 무엇인지 확인이 가능하므로) * todo.printTagRelate 함수 완성, todo.add함수에서 버그를 발견함 * 새로운 객체 안 배열에 저장하도록 만들어 문제 해결 * remove함수를 호출했을때, saveData.task배열에서 지워지는것 뿐 아니라 saveData.idArrays배열에서도 id를 지워지게 수정 * 테스트코드를 주석처리함 들여쓰기를 다시 맞춤 * saveData객체를 없애고 그 내용을 todo객체 안으로 집어 넣음, todo.idArrays의 값은 todo.add를 호출할때마다 추가되도록 수정. * if(saveData.idArrays.indexOf(ranNum) !== -1)-> if(this.idArrays.includes(ranNum))으로 변경 * 기나긴 삼항연산자 statusNum[obj.status]++로 해결 * todo.update함수에서 바뀐 상태의 상태를 반영하지 않는 버그를 찾아내서 수정 * 함수마다 간단한 주석을 달아줌 * 주석추가 * 피드백을 위한 주석 추가 * 같은 숫자를 반복하는 것을 todo.task로부터 찾아와 sync가 완벽하게 맞도록 수정 * 쓸데없는 todo.idArrays에 쓰이는 배열과 메서드 제거 * 변수명 변경 * add나revmoe, update함수를 입력할때마다 각각 인자를 다르게 받아 다르게 출력하는 함수를 만듬 * 해야할 일들 주석으로 정리 * 만들어야 할 함수들 미리 작성 * time obj를 saveTimeObj로 이름을 변경하고 saveTimeObj에 doing일때의 시간과 done일때의 시간을 인자로 입력받아 경과된 시간을 반환해주는 getTakeTime 함수 구현 * 업데이트할 객체를 인자로 받아 id값과업데이트 될때의 시간 값을 saveTImeObj의 객체에 저장해주는 함수 구현 * todo.add함수에서 새 객체를 만들때 걸린시간 이라는 항목을 추가함 * timeobj객체를 todo안으로 집어넣어 활용하기로 결정, 수정 * doingTimeArray와 takenTimeArray가 굳이 필요할것 같이 않아서 제거, 대신 task배열내의 객체에 timeData추가. 이를 이용해 updateDoingTime메서드 완성 * updateTakeTime메서드 구현. id가 같은 task.timeData값에 걸린 시간을 계산해서 저장해줌 * showTag메서드와 그 메서드를 위한 printByTag메서드 구현. printByTag는 tag과 status를 인자로 받아 같은인자와 tag를 출력, showTag메서드는 그 값을 세번 불러서 서로다른 3가지의 status값을 모두 출력. * show메서드 구현 만약 status가 done상태일때만 시간을 출력해주도록 함 * printByTag메서드의 버그 수정(상태가done인 항목을 입력해도 걸린 시간이 나오지 않았음), show메서드의 버그 수정(상태가done이면 doing항목을 출력하라고 입력했을때 done항목도 같이 출력되었었음) * 테스트 케이스 추가 * showAll메서드 구현, bind메서드를 이용함 * 같은태그를가짐과동시에 같은상태인것의 개수를 세는 함수 getSameTagAndStatusNum함수를 만듦 * show함수를 좀더 보기좋게 수정 * showTags를 위한 getSameTagArrays와 printSameTag함수를 만듬. 태그의 모든값이 담긴 배열을 만들고, 배열의 값을 통해 같은 값을 출력하는 함수를 만듬 * 태그가 같은 할 일의 개수를 계산해주는 함수 getSameTagNum을 만듬 * 함수의 쓰임새에 따라 정렬하여 보기편하게 수정 * 테스트 케이스들을 모두 주석처리하고 id의 경우의 수를 100가지로 늘림 * 사소한 버그 수정
saveData라는 객체에 할일들의 배열과 id들의 배열을 저장해서 계속해서 사용하는 구조로 만들어 보았습니다.