Part 1 - Refactoring 101
What is refactoring?
Reasons to Refactor
Refactor v.s. Rewrite
From developers view
Part 2 - A Case Study: X2R
What is X2R and What it does?
Reasons to Refactor in X2R
Code review in X2R component - USS
Refactoring USS with symfony2
3. In This Talk
• Part 1 - Refactoring 101
• What is refactoring?
• Reasons to Refactor
• Refactor v.s. Rewrite
• From developers view
• Part 2 - A Case Study: X2R
• What is X2R and What it does?
• Reasons to Refactor in X2R
• Code review in X2R component
- USS
• Refactoring USS with symfony2
8. • Code is duplicated.
• A function is too long.
• A loop is to long or too deeply nested.
• Global variables are used.
• A function has a poor name.
• Comments are used to explain difficult code.
• And more…
Code Complete - Chapter 24
10. • Code refactoring is the process of restructuring
existing computer code - without changing its external
behavior. (Wikipedia)
• “a change made to the internal structure of the soft-
ware to make it easier to understand and cheaper to
modify without changing its observable
behavior” (Fowler 1999).
Code Refactoring
https://www.flickr.com/photos/pascalbrax/5429971163
11. Code Rewrite
A rewrite in computer programming is the act or result
of re-implementing a large portion of existing
functionality without re-use of its source code or
writing inscription.
12. From developers view
Refactor v.s. Rewrite
http://www.groomers-online.com/news/wp-content/uploads/2013/04/dog-computer.jpg
22. • Code is duplicated.
• A function is too long.
• A loop is to long or too deeply nested.
• Global variables are used.
• A function has a poor name.
• Comments are used to explain difficult code.
• And more…
Code Complete - Chapter 24
23. A brief of code review in X2R
components:
URI Search Service (USS)
24. 24
Input: search term
1. - Compose query and filter the endpoint-list
to extract requested endpoint URL.
Loop
2.1 - Connect individual endpoint and send
query
Loop
2.2 - Integrates resultsLoop
Output: Results
26. The Refactoring Strategies in general
• Easy to maintain both Front&Back end
• Separate different classes and function
• restructuring existing code and logic
• DRY - Don’t repeat yourself
27. The Refactoring Strategies in Symfony2
• MVC - Model-View-Control pattern
• Modularized - Reusable functions of X2R
• Symfony2 Components
28. A brief of Demo after
refactoring with symfony2