Programming 11

[Python] 나의 리팩토링 규칙 #1

개요 최근 python 코드를 리팩토링하는 일이 많은데, 그 이유는 분석을 잘하기 위해서다. 기존 시스템 코드 대부분이 남이 만든 코드가 90% 이상인데, 읽기 좋은 코드는 아니다. 물론, 리팩토링을 하지 않아도 분석 할 수는 있다. 하지만, 나는 리팩토링을 했다. 왜? 기존 코드를 그대로 분석 vs 리팩토링 + 가독성 개선 후 분석 에 들어가는 리소스(시간)만 봤을때 후자가 더 효율적이기 때문이다. (이 이야기는 여기서 길게 할 필요는 없으므로 생략한다..) 여튼, 리팩토링을 계속 하면서 반복되는 패턴이 생겨, 이 글에서 규칙을 정리하려 한다. 보편적인 python 코딩 컨벤션의 기본적인 내용도 일부 포함된다. 규칙 import 문 정리 import 문을 알파벳 순서로 정렬한다. IDE를 통해 없는 p..

Programming/Python 2024.03.11

What should main() return in C and C++?

In C90, main() must have an explicit return statement at the end to avoid undefined behaviour. In C99 and newer, you may omit the return statement from main(). If you do, and main() finished, there is an implicit return 0. C90에선 main() 함수에서 무조건 반환 타입을 정의 해야했지만, C99부터 묵시적으로 return 0 를 수행하기 때문에 생략가능해졌다. 참고 : https://stackoverflow.com/questions/204476/what-should-main-return-in-c-and-c

Programming/C++ 2023.04.04

깃랩 이모지 gitlab emojis

gitlab 사용하다보면 이모지 쓰기가 어렵다 따로 메뉴가 없고 이모지 코드를 써야하는데 괜찮은 cheat sheet이 있어서 메모한다. https://github.com/yodamad/gitlab-emoji GitHub - yodamad/gitlab-emoji: You love emojis 😄 ? You love Gitlab ? You love emojis 😄 ? You love Gitlab ? Contribute to yodamad/gitlab-emoji development by creating an account on GitHub. github.com 아래 이거 퍼온건데 우리쪽 gitlab 저장소에도 적용해봐야겠다. 귀엽네.

Programming 2023.03.09

Start a Git commit message with a hashmark (#)

현회사 컨벤션 중 커밋 메세지에 #으로 시작하는 부분이 있는데, git bash 에서 하려니 생략되어 버림. 왜냐하면 #을 주석으로 처리하기 때문인데.. git commit -a 를 하게 되면 아래처럼 자동으로 주석이 생긴다. 검색해보니 stack overflow 형님들이 알려주신다 https://stackoverflow.com/questions/2788092/start-a-git-commit-message-with-a-hashmark Start a Git commit message with a hashmark (#) Git treats lines starting with # as comment lines when committing. This is very annoying when working wit..

Programming 2023.03.09

clang-tidy modernize-pass-by-value 문서 번역 및 해설

modernize-pass-by-value With move semantics added to the language and the standard library updated with move constructors added for many types it is now interesting to take an argument directly by value, instead of by const-reference, and then copy. This check allows the compiler to take care of choosing the best way to construct the copy. 언어에 이동 의미론(move semantics)이 추가되고 많은 타입에 대한 이동 생성자(move c..

Programming/C++ 2022.12.13

[C/C++] Comma Operator 콤마 연산자

아래 처럼 조건문에서 입력과 조건체크를 함께 진행하는 경우 유용할 수 있습니다. if (numeric_read(str, &err), !err) numeric_read함수는 호출만 되고, !err 조건만 판단하게 됩니다. 콤마 연산자에 대한 자세한 설명은 아래 링크들을 참고해주세요 https://dad-rock.tistory.com/117 https://www.inflearn.com/questions/137837 https://stackoverflow.com/questions/16475032/comma-operator-in-if-condition

Programming/C++ 2022.06.17

can't delete incomplete type

class SessionImpl; class Session { public: Session() = default; virtual ~Session() = default; private: std::unique_ptr pImpl_; }; 이 코드를 빌드하면 visual studio 에서 아래 오류가 발생한다. 오류 C2027 정의되지 않은 형식 'SessionImpl'을(를) 사용했습니다. 경고 C4150 불완전한 형식 'SessionImpl'에 대한 포인터를 삭제했습니다. 소멸자가 호출되지 않습니다. 오류 C2338 can't delete an incomplete type 이유는 SessionImpl 이 전방선언되어 있고 Session의 생성자/소멸자가 SessionImpl의 정의를 알 수 없기 때문이다. ..

Programming/C++ 2021.05.17

전문가를 위한 c++ 개정4판 오탈자 등록

전문가를 위한 c++ 개정4판 읽던 도중 내용이 잘못된것 같아 오탈자 등록을 했다. https://www.hanbit.co.kr/store/books/look.php?p_code=B3215427289 전문가를 위한 C++(개정4판) C++는 마스터하기 어렵기로 악명 높지만 풍부한 기능 덕분에 게임이나 상용 소프트웨어 애플리케이션을 개발하는 대표 언어로 자리매김했다. 숙련된 C++ 프로그래머조차 잘 모르는 고급 기능도 www.hanbit.co.kr string_view의 remove_prefix와 remove_suffix동작이 스트링을 축소하려면 시작포인터를 뒤로 보내고 끝포인터를 앞으로 당겨야 하는데, 포인터를 보내는 방향이 반대로 써있는것 같아서 내용 확인 요청을 작성했다. 책 내용이 많다보니 단순 실..

Programming/C++ 2021.05.07