분류 전체보기
-
객체지향 프로그래밍분석과탐구 2023. 10. 22. 00:42
객체지향 프로그래밍 객체지향 프로그래밍을 이야기하다 보면 개체지향 프로그래밍이란 용어도 보게 된다. 개체는 시스템 안에서 협력하는 개념에 가깝고, 객체는 독립성을 가진 대상을 가리키는 쪽에 가깝다. 객체지향의 object는 개념상으론 개체 쪽에 가까운 것으로 보이는데, 개체보단 객체라는 단어가 주로 쓰인다. MSDN에선 개체지향 프로그래밍으로 명시한다. 일단, 객체가 좀 더 널리 쓰이니, 객체로 하겠다. 객체지향 프로그래밍에 대하여 글을 쓴 계기는 객체지향의 사실과 오해라는 책을 읽고 생각을 정리하고 싶어서다. 책 1권만 읽은 사람이 가장 무섭다던데, 책을 그대로 요약할 필요는 없어 보이고 여태까지 배운 것들, 경험한 것들을 짬뽕하여 내가 생각해본 객체지향을 정리할 생각이다. 객체지향과 절차지향 객체지향..
-
Laravel, 리퀘스트에서 불필요한 필드가 있으면 자동으로 반려하기문제해결 2023. 9. 27. 18:13
서버의 요청 처리 과정 서버가 받은 요청을 처리하는 과정은 다음과 같다. 검증 -> 추출 -> 정제 -> 로직 -> 응답 집중해서 보고 싶은 부분은 검증과 추출의 일부분이다. 검증은 서버에 들어오는 요청에 API 스펙으로 정한 필드의 유무와 필드가 있다면 타입 등의 제약 사항을 제대로 지키는지 확인하는 데 사용된다. 추출은 검증 후에 로직에 맞게 필요한 데이터를 가져오는 과정이다. 라라벨은 검증에 필요한 도구를 제공한다. 밸리데이터, 폼리퀘스트 등이 있을 것이다. 그러나, 일반적인 상황에서 벗어난 것들은 직접 만들어줘야 한다. 이 글에서 다룰 내용은 요청 안에 스펙에 없는 필드가 왔을 때 자동으로 반려하는 것이다. 검증할 요소들 요청에서 검증할 요소들은 다음과 같다. 반드시 존재해야 하는 필드. 라라벨에..
-
flex-grow, shirink, basis짧은경험기 2023. 8. 18. 09:08
flex-grow, shirink, basis flex-grow, shirink, basis는 flex container에 속한 flex item의 크기 비율을 결정한다. flex-grow는 container가 점유한 공간의 비어있는 곳을 채우기 위해 아이템을 늘릴 비율을 의미한다. flex-shirink는 container가 점유한 공간이 좁아 아이템의 크기를 유지할 수 없어 아이템을 줄이기 위한 비율을 의미한다. flex-basis는 container안에서 아이템이 얼마만큼 공간을 점유할지 결정하는 초기값이다. 아이템이 늘어나고 줄어날 때의 방향은 flex-direction에 의하여 결정된다. 다음 상황을 가정해 보자. flex container가 점유하는 노란색 공간이 있고, 청녹적의 세 박스가 f..
-
패딩이 적용된 블록 엘리먼트에 높이로 트랜지션하기짧은경험기 2023. 8. 1. 19:36
개요 패딩이 적용된 블록 엘리먼트에 높이를 기준으로 트랜지션을 하려고 시도하면 두 가지 문제가 발생한다. 시작 상태에 height 속성을 0으로 지정하더라도, 패딩에 의하여 공간이 확보되어 해당 엘리먼트 안의 내용물 보인다. 트랜지션 롤백 과정의 마지막에 엘리먼트 안의 내용물이 감춰지지 않는다. 예시 Hello World 블록 엘리먼트에 패딩을 1em만큼 주고 height을 0으로 하면 어떤 결과가 나올까? 다음 이미지를 보자. 왜 이런 결과가 나온 걸까? 패딩에 의하여 블록 엘리먼트의 공간이 확보되고 height: 0 속성이 무시된다. 엘리먼트는 최소 padding의 top, bottom 크기만큼의 높이를 갖게 되는 것이다. 그 결과, 가리기를 원했던 글이 보인 것이다. 이 상태에서 height을 변경..
-
JWT와 세션분석과탐구 2023. 7. 22. 09:55
Why avoiding LocalStorage for tokens is the wrong solutionJWT JWT는 토큰이다. 토큰은 일련의 문자열을 의미한다. JWT는 일련의 문자열을 서버와 클라이언트가 주고받아 서로 통신하기 위한 도구이다. JWT는 '헤더.페이로드.사인'으로 이루어진 문자열이다. 헤더, 페이로드는 json으로 이루어져 있고, 사인은 헤더와 페이로드를 시크릿키로 암호화한 값이다. 클라이언트와 서버가 주고받을 때 base64로 인코딩 되어 전송한다. 누군가 JWT를 얻었다면, base64 디코딩을 통하여 간단히 내용을 확인할 수 있다. 그래서 JWT 안에 중요한 데이터를 보관하는 것은 좋은 방향이 아니다. JWT는 위조방지 기능이 있는 토큰이다. 서버가 가진 시크릿키를 이용하여 헤더..
-
라라벨 프로젝트 진행중에 문제해결문제해결 2023. 7. 13. 23:11
문제해결 라라벨 프로젝트를 진행하며 경험한 문제와 그 해결방법을 기록 1. 개발 환경 구축 라라벨은 라라벨 Sail, homestead 등의 개발 환경 구축을 위한 지원이 있음. Sail은 설치만 해보고 명령어만 써봐도 편한 것을 알 수 있었음. 그러나, 이것을 이용하지 않고 개발 환경을 직접 구축하기로 했음. 라라벨에 익숙해질 수 있을 것이고, 서버나 디비 세팅을 하면서 웹 개발 자체에 익숙해지는 효과를 기대했음. 이전에 php-apache 도커 이미지를 기반으로 세팅해 본 경험이 있기에 할만하다고 기대했음. 먼저 php-apache, mysql 기본 이미지를 기반으로 도커 파일을 생성하여 라라벨 코드를 도큐먼트 루트에 마운팅 하여 실행했음. 에러가 나서 화면이 안 나오는 것이라 생각할 정도로 매우 느..
-
락이 필요한 경우 어떻게 처리할까 고민분석과탐구 2023. 6. 9. 07:03
락이 필요한 경우 어떻게 처리할까 고민 데이터베이스에서 락을 쓰면 실수할 여지가 꽤 있는데, 문제가 발생했을 때 데드락 같이 여파가 큰 문제가 발생한다. 격리 수준에 따른 락의 차이를 고려하면서, 데드락을 방지하기 위해 테이블의 접근 순서는 이래야 하는 등의 일은 너무나도 실수가 발생할 여지가 크다. 그런데, 락은 필요하다. 상품의 재고, 티켓팅, 주문 처리 등등 모두 한 번에 하나의 실행흐름이 접근해서 처리해야 하기 때문이다. 그래서 어떻게 처리하나 찾아보니, 인프런에서 좋은 답변을 찾았다. 인프런의 질문답변 게시판에서 얻은 힌트 강사님 락관련 질문이 있습니다. 요약하자면 쇼핑몰 같은 시스템에서 락이 필요해 보이는데, 어떻게 해야 하냐는 것이다. 답변을 일부 발췌하였다. 락을 거는 것은 요즘 같은 실시..
-
도커로 MySQL 다루기분석과탐구 2023. 6. 9. 02:50
도커로 MySQL 다루기 MySQL을 사용할 때, MySQL을 따로 설치하지 않고 도커 이미지로 가져와 컨테이너로 돌려서 사용하곤 했다. 도커 데스크탑과 컴포즈로 인해서 연관된 프로그램들을 하나로 묶는다는 개념이 좋았기 때문이다. 설치와 설정의 반복에서 벗어나 docker-compose.yml파일을 하나 잘만들어두면 여기저기 쓸 수 있어서 좋기도 했다. 그래서, 사용하면서 그때 그때 처리하고 넘어갔던 것들을 정리해보려고 한다. 예제 링크 설정파일 변경 mysql의 설정파일은 /etc/my.cnf에서 다룬다. 설저을 바꾸기 위해서 my.cnf를 직접 수정하는 식으로 접근하면, 적어도 컨테이너에서는 여러 에러가 발생한다. 에러를 해결하기 위해 이런저런 명령어를 쓰는 것도 나쁘진 않지만, my.cnf파일을 보..