-
KISS
Keep It Simple Stupid!
-
YAGNI
You Ain't Gonna Need It!
-
DRY
Don't Repeat Yourself!
[참고 서적] https://book.naver.com/bookdb/book_detail.nhn?bid=16311029
Details
- Extract Method
- Inline Method
- Extract Variable (Introduce Variable)
- Inline Temp
- Replace Temp with Query (= Extract Method + Inline Temp)
- Split Temporary Variable
- Remove Assignments to Parameters
- Replace Method with Method Object
- Substitute Algorithm
- Move Method
- Move Field
- Extract Class
- Inline Class
- Hide Delegate
- Remove Middle Man
- Introduce Foreign Method
- Introduce Local Extension
- Consolidate Conditional Expression
- Consolidate Duplicate Conditional Fragments
- Decompose Conditional
- Replace Conditional with Polymorphism
- Remove Control Flag
- Replace Nested Conditional with Guard Clauses
- Introduce Null Object
- Introduce Assertion
- Add Parameter
- Remove Parameter
- Rename Method
- Seperate Query from Modifier
- Parameterized Method
- Introduce Parameter Object
- Preserve Whole Object
- Remove Setting Method
- Replace Parameter with Explicit Methods
- Replace Parameter with Method Call
- Hide Method
- Replace Constructor with Factory Method
- Replace Error Code with Exception
- Replace Exception with Test
- Pull Up Field
- Pull Up Method
- Pull Up Constructor Body
- Push Down Field
- Push Down Method
- Extract SubClass
- Extract SuperClass
- Extract Interface
- Collapse Hierarchy
- Form Template Method
- Replace Inheritance with Delegation
- Replace Delegation with Inheritance
Details
// ConcurrentModificationException Case
ArrayList<String> list = new ArrayList<String>();
for(String name : list){
list.remove(name);
}
// Solution 1
ArrayList<String> list = new ArrayList<String>();
ArrayList<String> Remove = new ArrayList<String>();
for (String name : list)
Remove.add(name);
for (String name : Remove)
list.remove(name);
// Solution 2
ArrayList<String> list = new ArrayList<String>();
Iterator<String> iter = list.iterator();
while (iter.hasNext()) {
String s = iter.next();
iter.remove();
}