[데이터 엔지니어링 데브코스 2기] TIL-5주차-파트06 [프로젝트]크롤한 웹데이터로 만들어보는 웹사이트(5) / 특강(좋은 코드란 무엇인가)
1. 프로젝트
1-1. 진척 사항
- 코디숍에 대한 스크래핑은 완료되었으며, csv 파일로 저장하였다.
- 코디맵에 대해서 스크래핑 진행 중이다.
1-2. 추후 계획
- 크롤링 및 스크래핑하는 코드를 리팩토링함으로써, 좀더 클린한 코드로 만들어 본다.
- DB 쓰기 작업 관련하여 코드를 확인해 본다.
- DB 쓰기 작업이 완료되면 바로 코드를 테스트해 볼 수 있도록, DB 설정을 한다.
1-3. 회의 내용
1-4. 몰랐던 내용
- PostgreSQL Insert에서 '-' 하이픈에 대한 처리가 잘 안된다는 것을 알았다.
- 클린한 코드를 만들기 위한 몇 가지 원칙(?) or 구글 문서와 같은 규칙 문서 등을 알았다. => 특강 강의 자료 참고.
1-5. 피드백
- 스크래핑 코드에서 element를 읽어올 때, default를 입력함으로써 None 값에 대한 예외처리가 필요할 것 같다.
- logging 시에 크롤링하려는 page#를 함께 입력함으로써, log 파일을 읽을 때 어느 페이지에서 문제가 발생했는지 등에 대한 정보를 알면 좋을 것 같다.
- 코디숍과 코디맵의 코드가 거의 중복되는 것이 많으므로 하나의 클래스로 만들어, 클래스 내부에서 코디숍과 코디맵에 대한 메소드로 나누는 것이 더 좋을 것 같다.
- 불필요한 주석이 많은 것 같다.
2. 특강 : 좋은 코드란 무엇인가?
2-1. 마음가짐
- 처음 보는 개념에 대해서 긍정적으로 바라보자. 아직은 낯설지만 언젠가는 익숙해질 것이다.
- 천천히 오랫동안 학습하며, 멀리 보는 시각을 갖자. 지금 당장은 목표를 이루지 못해도 언젠가는 이룬다는 마음가짐으로 임하자.
- 스톡데일 신드롬 : 언젠가는 목표를 이룬다는 마음가짐.
2-2. 코드 관련
- 코드를 짜기 전에, 어떻게 코드를 test할 지를 고민해 보고 작성하자.
- 중복되는 코드를 피하자.
- ChatGPT 등을 활용하여 기초 뼈대를 갖춘 코드를 가지고 작업을 시작하자.
- 읽어보면 좋은 책들
● "Clean Code: A Handbook of Agile Software Craftsmanship" by Robert C.
Martin
● "Code Complete: A Practical Handbook of Software Construction" by Steve
McConnell
● "The Pragmatic Programmer: From Journeyman to Master" by Andrew Hunt
and David Thomas
● "Refactoring: Improving the Design of Existing Code" by Martin Fowler
● "Design Patterns: Elements of Reusable Object-Oriented Software" by Erich
Gamma, Richard Helm, Ralph Johnson, and John Vlissides
- 읽어보면 좋은 온라인 자료
● Writing clean and readable code:
○ https://www.freecodecamp.org/news/writing-clean-code-tips-and-tricks-for-new-developers/
● Consistent formatting and naming conventions:
○ https://google.github.io/styleguide/
● Using meaningful and descriptive variable names:
○ https://www.thoughtco.com/why-variable-names-are-important-373316
● Proper commenting and documentation:
○ https://www.codecademy.com/articles/how-to-document-your-code
● Writing effective test cases:
○ https://www.guru99.com/effective-test-cases.html
● Understanding Git and version control:
○ https://www.atlassian.com/git/tutorials/what-is-git