전체 글
-
항해 99 5기 TIL_31항해 99 2022. 2. 10. 02:32
▶ Today I Learned 이번엔 또 다른 테스트 코드를 보다 문득 궁금해졌다. describe('Sensor 요구사항 테스트', () => { beforeEach(() => { jest.useFakeTimers(); }); afterEach(() => { jest.clearAllTimers(); }); beforeEach()? afterEach? jest의 공식문서를 보면 before Each()는 다음과 같다. Runs a function before each of the tests in this file runs. If the function returns a promise, Jest waits for that promise to resolve before running the test. 즉,..
-
항해 99 5기 TIL_30항해 99 2022. 2. 9. 05:22
▶ Today I Learned [그리디 알고리즘] 탐욕법이라고도 칭함, 매 순간 가장 좋아보이는 선택을 하며 나중에 끼칠 영향에 대해서는 고려하지 않음. 그래서 단순 무식하게, 탐욕적으로 푸는 방법이라고 하나보다. 모든 문제에 통하는 방식은 아니며 동적 프로그래밍을 보완해주기위한 느낌으로 쓰이는 듯 하다. 해당 알고리즘으로 매 순간 가장 좋아보이는 선택을 하기에 보통 가장 큰 단위부터 풀어나가는 경우가 많아보이나, 사용자가 정답을 찾을 때 세운 조건에 가장 가까운 값을 선택하는 것이 해당 알고리즘에 더 맞는 설명이라고 본다. 그것이 항상 큰 단위일 수 없는게 만약 사용자가 정답을 구하기 위해 '배열 내 값 중 최솟값을 구해야 해!' 라고 생각했다면 가장 작은 단위가 기준이 되어 작은 수부터 찾아나가는 ..
-
항해 99 5기 TIL_29항해 99 2022. 2. 7. 23:53
▶ Today I Learned 신고결과 받기 (카카오 블라인드 테스트 - 프로그래머스 레벨 1) 소요시간: 1시간 시간 내 문제해결 여부: 미해결 https://programmers.co.kr/learn/courses/30/lessons/92334 let id_list = ["muzi", "frodo", "apeach", "neo"] let report = ["muzi frodo","apeach frodo","frodo neo","muzi neo","apeach muzi"] // ["ryan con", "ryan con", "ryan con", "ryan con"] let k = 2 // 예상 결과 result 값 [2,1,1,0] // 문자열 알파벳 소문자, 중복 아이디 x 동일 유저 신고 여려번 해..
-
항해 99 5기 WIL_4항해 99 2022. 2. 6. 23:38
▶ Weekly I Learned (회고) 이번 주도 열심히 달려온 한 주였다. 비록 지난 주차의 과제를 마무리 짓지 못하였지만 이번 주차의 과제를 빠르게 마무리 짓고 못 다한 것을 마무리 지을 예정이다. 이번 주차는 이해만 빠르면 금방 해결할 수 있는 것들이기에 가능할 것이라고 본다. 당장은 잘하지 못해도 또 실력이 늘거라 믿는다. 화이팅팅 :) [ORM] Object Relational Mapping: 객체 관계 매핑 객체와 관계형 데이터베이스의 데이터를 자동으로 매핑(연결)해 주는 것, 객체지향 프로그래밍에선 클래스를 사용한다면 관계형 데이터는 테이블 사용 -> 객체 모델과 관계 모델 사이에 불일치 생김 -> ORM이 객체간의 관계를 고려하여 SQL을 자동으로 생성함으로써 불일치 해결 장점 1) 코..
-
항해 99 5기 TIL_28항해 99 2022. 2. 6. 10:21
▶ Today I Learned [Jest] 페이스북에서 만들어진 테스팅 라이브러리, Test Runner, Test Matcher, Test Mock 프레임워크까지 제공해주기에 편히 사용할 수 있다는 장점이 있음, 그러나 Mocha보다 느리다고 함 [객체 간 비교 vs 원시자료형 간 비교] 테스트 코드를 시행 함에 있어서 다음의 코드를 작성하였다. if (this.boards.includes(board)) { throw this.addBoard(board); } else { this.boards.push(board); // push에 성공하면 // Site { boards: [ Board { name: '공지사항' } ] } 라는 모양이 된다. board라는 객체 값을 site라는 배열 안에 중복으로 ..
-
항해 99 5기 TIL_27항해 99 2022. 2. 6. 00:19
▶ Today I Learned [ELF] Executable and Linkable Format, 요즘 많이 쓰이느 매개 파일 형식 프로그램을 여러개의 조각으로 나눔에 따라 모든 조각을 하나로 엮을 방법이 필요해짐 -> 각 프로그램을 연결하기 편한 매개 파일로 나누고 이를 링커(linker)를 사용해 하나로 연결하여 실행가능 [코드 분리] 개발자가 코드를 구분해주는 것이 가독성 측면에서 좋다. 그 중에는 쓰임새에 따라 코드를 구분하는 방법도 있다. 예를 들어 아래와 같은 두 함수가 있다고 치자. function sum (a, b) { return a + b; } function sumPrice (a, b) { return a + b; } 둘은 모두 a와 b의 합을 반환해주고 있다. 구조도 똑같아 보이고..
-
항해 99 5기 TIL_26항해 99 2022. 2. 5. 01:26
▶ Today I Learned [캐시] 과거 CPU와 메모리는 비슷한 속도였지만 컴퓨터 발전에 따라 CPU는 빨라진 반면 메모리는 그 속도를 따라가지 못했다. 이렇게 되면 CPU가 메모리를 기다리는 동안 아무 일도 하지 않는 현상이 발생할 수 있고 이를 해결하기 위해 생겨난 방법 중에는 캐시가 있다. 캐시는 쉽게 말해 별도의 저장고 같은 곳이다. 반복적으로 쓰는 데이터를 서버나 DB에 요청하지 않고 메모리에 저장해두는 것이다. 그렇게 되면 이 다음 사용시 해당 데이터를 또 불러올 필요가 없으므로 성능이 대폭향상된다. 여기서 원하는 데이터가 캐시에 존재하지 않을 경우 캐시 미스(Cache Miss), 존재할 경우를 캐시 히트(Cache Hit)라고 부른다. 기본적으로 캐시의 저장 공간은 작기 때문에 캐시..
-
항해 99 5기 TIL_25항해 99 2022. 2. 4. 01:47
▶ Today I Learned [댓글 수정 구현] /* 댓글정보 불러와서 표시 */ async function getComments() { $('#tableBody').empty() try { const response = await axios.get("/api/get-comments"); console.log('댓글정보 불러오기', response.data) let arr = response.data.comment let i = 0; let orderNumber = 0 let comment_temp for (i; 0 < arr.length - i; i++) { //최신 댓글이 위로 오도록 거꾸로 나열 if (arr[arr.length - i - 1].postingId === id) { // posti..