-
항해 99 5기 TIL_27항해 99 2022. 2. 6. 00:19
▶ Today I Learned
<CS 스터디>
[ELF]
Executable and Linkable Format, 요즘 많이 쓰이느 매개 파일 형식
프로그램을 여러개의 조각으로 나눔에 따라 모든 조각을 하나로 엮을 방법이 필요해짐
-> 각 프로그램을 연결하기 편한 매개 파일로 나누고 이를 링커(linker)를 사용해 하나로 연결하여 실행가능
[코드 분리]
개발자가 코드를 구분해주는 것이 가독성 측면에서 좋다.
그 중에는 쓰임새에 따라 코드를 구분하는 방법도 있다.
예를 들어 아래와 같은 두 함수가 있다고 치자.
function sum (a, b) { return a + b; } function sumPrice (a, b) { return a + b; }
둘은 모두 a와 b의 합을 반환해주고 있다. 구조도 똑같아 보이고 이 둘은 같은 함수라고 생각할 수 있다.
하지만 둘은 이름에서 보이듯 용도가 달라보인다. sum은 말 그대로 정말 합만을 보여주는 듯하고
sumPrice는 가격 총액을 보여준다. 그렇다면 이 둘은 구분지어주는 게 좋다.
왜냐하면 추후 sumPrice라는 함수는 수정이 일어날 수 있기 때문이다.
어떤 회사에서 세일 기간이라 위 함수에서 b라는 가격을 10% 할인하는 기능을 추가하기로 했다.
그렇다면 b부분을 수정할 것이다. 반면 sum함수는? 수정할 수 없다.
이름 자체에서 단순히 값의 합이라는 걸 정의하고 있기 때문이다.
언제나 가독성 높은 코드, 성능 좋은 코드 등 코드 하나를 짤 때에도 고려하거나 지켜야할 관습이 있는게 개발자들이다.
[socket]
양뱡향 통신을 가능하게 해주는 연결부,
많이 쓰이는 것으로는 TCP 소켓과 UDP 소켓이 있음
ex) 채팅어플에서 내가 메시지를 보냈는데 상대방 쪽에선 받지 못할 때
-> TCP라면 안정성을 보장해주고자 메시지를 다시 받을 수 있음, UDP는 이를 보장해주지 않음
socket io란?
웹소켓을 이용한 라이브러리, 웹에서 실행되는 소켓인 웹소켓이 있는데 이는 아직 모든 브라우저에서 호환되는 것은 아님
->socket io는 모든 브라우저에서 똑같이 호환되므로 사용이 권장됨
<TDD>
[테스트 코드]
종류
단위 테스트 (Unit Test): 가장 작은 단위를 테스트
통합 테스트(Integration Test): 여러가지 기능을 합하여 테스트
E2E 테스트 (End-to-end Test): 백엔드와 프론트엔드의 처음부터 끝까지 다 테스트
추후 실력이 올랐을 땐 E2E로 하는게 좋다고 한다. 그게 실생활과 가장 가까울 테니 이해할 법하다.
Jest: 자바스크립트 테스팅 코드 프레임워크. 다른 테스팅 프레임워크에 비해 테스트 코드의 표현이 훨씬 간결하다.
▶ 느낀 점
테스트 코드를 작성하는 문제에서 생성자와 객체, 클래스에 대한 개념이 나왔다. 자바 공부 이후 오랜만이라 개념공부하는데
많은 시간이 들었다. 아직도 이해한 것은 아니나 조금 더 알게되었다.
내일은 우선 문제를 풀어보면서 다시 필요한 부분의 개념만 찾아보도록 하자!
화이팅팅! :)
▶ 공부 시 참고 링크들
https://androidkim.tistory.com/4
https://velog.io/@04_miffy/%ED%95%A8%EC%88%98-1
https://poiemaweb.com/es6-class
'항해 99' 카테고리의 다른 글
항해 99 5기 WIL_4 (0) 2022.02.06 항해 99 5기 TIL_28 (0) 2022.02.06 항해 99 5기 TIL_26 (0) 2022.02.05 항해 99 5기 TIL_25 (0) 2022.02.04 항해 99 5기 TIL_24 (0) 2022.02.03