Refactoring Seminar

24
Introduction to Refactoring Step 1 What, Why, When, How [email protected]

Transcript of Refactoring Seminar

Page 1: Refactoring Seminar

Introduction to Refactoring

Step 1What, Why, When, How

[email protected]

Page 2: Refactoring Seminar

What is refactoring

• Fowler's definition “A change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior”

Page 3: Refactoring Seminar

Why

Page 4: Refactoring Seminar

Bad Smell

Page 5: Refactoring Seminar

Good Smell

Page 6: Refactoring Seminar

When

Page 7: Refactoring Seminar

Bad Smell

Page 8: Refactoring Seminar

Iterative

Page 9: Refactoring Seminar

Unit test

Unit

test

Page 10: Refactoring Seminar

How : Extract

Page 11: Refactoring Seminar

Extract Class

Page 12: Refactoring Seminar

Extract Method

Page 13: Refactoring Seminar

Remove

Page 14: Refactoring Seminar

Remove Middle Man

Page 15: Refactoring Seminar

Remove Setting Method

Page 16: Refactoring Seminar

Replace

Page 17: Refactoring Seminar

Replace Assignment with Initializa-tion

void foo() { int i; // .... i = 7; }

void foo() { // ... int i = 7; }

Page 18: Refactoring Seminar

Replace Constructor with Factory Method

Employee (int type) { _type = type; }

static Employee create(int type) { re-turn new Employee(type); }

Page 19: Refactoring Seminar

Hide

Page 20: Refactoring Seminar

Hide Delegate

Page 21: Refactoring Seminar

Hide Method

Page 22: Refactoring Seminar

Resources 1

1 장 . 리팩토링 비디오 2 장 . 리팩토링의 원리 3 장 . 코드에서의 나쁜 냄새 4 장 . 테스트 만들기 5 장 . 리팩토링 카탈로그로 ... 6 장 . 메쏘드 구성 7 장 . 객체간의 기능 이동 8 장 . 데이터 구성 9 장 . 조건문의 단순화 10장 . 메쏘드 호출의 단순화 11장 . 일반화 다루기 12장 . 대규모 리팩토링 13장 . 리팩토링 재사용 , 그리고 현실 14장 . 리팩토링 도구 15장 . 모두 합치기

Page 23: Refactoring Seminar

Resources 2• [ 항목 24] 컴파일 경고 메시지가 없게 하자 158• [ 항목 30] int 상수 대신 enum 을 사용하자 201• [ 항목 38] 매개 변수가 유효한지 검사하자 247• [ 항목 43] null 대신 비어있는 배열이나 컬렉션을 반환하자 274• [ 항목 45] 지역 변수의 유효 범위를 최소화 하자 285• [ 항목 47] 라이브러리를 배우고 사용하자 293• [ 항목 48] 정확한 계산에는 float 나 double 타입을 쓰지 말자

297• [ 항목 49] 박스화 기본형보다는 기본형을 사용하자 300• [ 항목 56] 보편화된 작명 규칙을 따르자 323• [ 항목 62] 메소드가 던지는 모든 예외를 문서화하자 344• [ 항목 63] 실패 상황 정보를 상세 메시지에 포함하자 346• [ 항목 64] 실패 원자성을 갖도록 노력하자 349

Page 24: Refactoring Seminar

Q&A