code refactoring · 2018. 3. 4. · spaghetti code program flow is conceptually like a bowl of...
TRANSCRIPT
![Page 1: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/1.jpg)
Code RefactoringPresented by Steven
Dec. 2016
![Page 2: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/2.jpg)
Why
2
![Page 3: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/3.jpg)
3
![Page 4: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/4.jpg)
4
![Page 5: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/5.jpg)
FastRunnable
5
![Page 6: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/6.jpg)
FastRunnable
6
![Page 7: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/7.jpg)
Spaghetti Code
● program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled.
● complex and confusing control structures that are barely understandable
7
![Page 8: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/8.jpg)
8
![Page 9: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/9.jpg)
What
9
![Page 10: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/10.jpg)
● Code refactoring is the process of restructuring existing computer code without changing its external behaviour.
Code Refactoring
10
![Page 11: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/11.jpg)
在不改變軟體的外在行為下,改善既有軟體的內部設計。
11
![Page 12: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/12.jpg)
2 Advantages
6 Techniques
12
![Page 13: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/13.jpg)
Advantages
13
![Page 14: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/14.jpg)
Expressiveness
14
![Page 15: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/15.jpg)
Expressiveness
Complexity
15
![Page 16: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/16.jpg)
Expressiveness
Complexity
Readability
16
![Page 17: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/17.jpg)
17
![Page 18: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/18.jpg)
Expressiveness
Complexity
Readability
18
![Page 19: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/19.jpg)
Maintainability
Expressiveness
Complexity
Readability
19
![Page 20: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/20.jpg)
Maintainability
Expressiveness
Complexity
Readability
Extensibility
20
![Page 21: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/21.jpg)
Maintainability Extensibility
21
![Page 22: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/22.jpg)
Techniques
22
![Page 23: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/23.jpg)
Generalization ExtractionEncapsulation
Pulling-up Pushing-downRenaming
23
![Page 24: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/24.jpg)
Generalization ExtractionEncapsulation
Pulling-up Pushing-downRenamingcommon: private / (default) / protected / public
24
![Page 25: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/25.jpg)
Generalization ExtractionEncapsulation
Pulling-up Pushing-downRenamingcreate more general types, e.g., super-classes
25
![Page 26: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/26.jpg)
Generalization ExtractionEncapsulation
Pulling-up Pushing-downRenamingextract {classes, methods, funcions}fewer methods → clearer purpose and functionality
26
![Page 27: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/27.jpg)
Generalization ExtractionEncapsulation
Pulling-up Pushing-downRenaming
rename {methods, fields}
27
![Page 28: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/28.jpg)
Generalization ExtractionEncapsulation
Pulling-up Pushing-downRenaming
moving methods between parent/child classes
28
![Page 29: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/29.jpg)
Generalization ExtractionEncapsulation
Pulling-up Pushing-downRenaming
http://refactoring.com/catalog/index.html29
![Page 30: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/30.jpg)
How
30
![Page 31: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/31.jpg)
Encapsulation 31
![Page 32: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/32.jpg)
Encapsulation 32
![Page 33: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/33.jpg)
data / field → private
Setter & Getter
Encapsulation 33
![Page 34: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/34.jpg)
Generalization 34
![Page 35: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/35.jpg)
Generalization 35
![Page 36: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/36.jpg)
Generalization 36
![Page 37: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/37.jpg)
Generalization 37
![Page 38: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/38.jpg)
Generalization 38
![Page 39: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/39.jpg)
Renaming 39
![Page 40: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/40.jpg)
Renaming 40
![Page 41: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/41.jpg)
Conclusion
41
![Page 42: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/42.jpg)
● what
42
![Page 43: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/43.jpg)
● whatMaintainability
Extensibility43
![Page 44: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/44.jpg)
44
![Page 45: Code Refactoring · 2018. 3. 4. · Spaghetti Code program flow is conceptually like a bowl of spaghetti, i.e. twisted and tangled. complex and confusing control structures that are](https://reader033.vdocuments.site/reader033/viewer/2022052011/602743b86523f54f3012dfd3/html5/thumbnails/45.jpg)
45