Refactoring 예제 내용 영화 대여 서비스 Customer의 statement Method에서 많은 역할을 수행하여 해당 Method의 리팩토링 필요 Refactoring 단계 statement Method에서 기능을 모듈화하고 적절한 class로 이동 Conditional Logic을 Price class로 추출 statement Method와 htmlStatement Method에서 공통된 부분을 추출 STEP1 : statement Method의 Decomposing & Redistributing 1-1) Extract Method switch 구문은 요금을 계산하는 기능을 함 > Method로 추출하자 >> Customer의 amountFor()로 추출 1-2) Move Method : :..
230302 수업 정리 리팩토링(Refactoring)이란? 소프트웨어의 internal quality attributes(Readability, Understandability) 향상하기 위해 목적 Readability : 가독성, 얼마나 읽기 좋은가 - Coding Style Understandability : 각 함수, 변수의 역할을 이해할 수 있는가 - 코드를 자세히 읽어야 한다면 Understandability를 충족하지 않음. 방법 Rename : 변수명, 함수명 바꾸기 Extract Constant : 상수 추출 Extract Variable : 변수 추출 - if문의 조건문 중 목적을 명시적으로 나타내는 지역변수를 사용 Extract Method : 함수 추출 - 주석으로 목적을 나타내기 ..
1. cin 2. 공백 입력 받기 (getline) split getline(cin, str); istringstream ss(str); string stringBuffer; vector x; x.clear(); while (getline(ss, stringBuffer, ' ')){ x.push_back(stringBuffer); } 배열의 이해 int (*A)[3]의 이해 : int[3]을 가리키는 포인터 A int(&ref)[3]의 이해 : int[3]을 참조하는 참조자 ref (배열의 래퍼런스는 반드시 크기를 명시해야 함) 함수 오버로딩 씹어먹는 C++ 참조 https://modoocode.com/173 C++ 컴파일러에서 함수를 오버로딩하는 과정 1 단계 자신과 타입이 정확히 일치하는 함수를 찾는..
그래프로 연결된 지역 중 한 지역을 제외했을 때, 가장 component가 많이 나오는 지역이 봉쇄지역이 된다. 만일 봉쇄지역이 여러개일 경우 연결된 weight의 합이 가장 큰 지역이 봉쇄지역이 됨. weight의 합이 같거나 봉쇄지역이 없을 경우 None 출력 STL사용하는게 익숙하지 않아서 버벅거리는게 심하다.. 그리고 코드 짜는 것도 많이 힘든거 같다. 셤 끝나고 바로 C++이랑 백준 달달달 볶아야지 달달달 #include #include #include using namespace std; typedef vector matrix; int n; matrix m; bool compare(pair& a, pair& b){ return a.second > b.second; } void DFS(int x..
// 커피를 쏟아서 이전 자료구조 파일을 다 잃어버렸다 ㅠㅠ // 잡담으로 파일이랑 채점 시스템의 입력 방식이 달라서 시간을 많이 썼다.. Floyd Warshall Algorithm의 응용 #include #include using namespace std; struct Node{ int data; vector neighbors; }; class Graph{ int num; Node* vertices; public: Graph(int n) { num = n; vertices = new Node[n + 1]; } int insertV(int data){ vertices[data].data = data; } int insertE(int from, int to){ vertices[from].neighbors..
* 본 게시글은 실습 과제를 복습하기 위해 작성한 글입니다. 학부생 수준에서 부족한 점이 많으니 수정할 부분 있으면 꼭 말씀해주세요 */ 문제 class Item { protected: string modelName; int price; string itemId; // “modelName-seqNumber” static int seqNumber; // initialValue = 1 }; class Monitor : public Item { const int size; }; class CPU : public Item { const int speed; }; class ItemList { vector items; }; int main() { ItemList list1; { CPU cpu1("Intel", 20..
/* 본 게시글은 실습 과제를 복습하기 위해 작성한 글입니다. 학부생 수준에서 부족한 점이 많으니 수정할 부분 있으면 꼭 말씀해주세요 */ 문제 아래 링크 참조 https://donkeysdevelpment.tistory.com/2 C++ 프로그래밍:: 상속(Inheritance) 실습 /* 본 게시글은 실습 과제를 복습하기 위해 작성한 글입니다. 학부생 수준에서 부족한 점이 많으니 수정할 부분 있으면 꼭 말씀해주세요 */ 문제 enum EmployeeLevel { 사원, 대리, 과장, 차장, 부장 }; cl donkeysdevelpment.tistory.com 해결 과정 class Employee constructor : 사원이름, 사원 레벨을 받고 이를 초기화해야함. 이때, 사원이름은 string 객..