You are on page 1of 11

(Refactoring)

Martin Fowler
Refactoring is the process of changing a software system in such
a way that it does not alter the external behavior of the code yet
improves its internal structure. It is a disciplined way to clean up
code that minimizes the chances of introducing bugs.
improving the design of the code after it has bean written.

(bug)

method
Input/Output(Parameters)(Return Value)
class Public Methods
Refactoring

Domain Layer

Domain Layer PatternTransaction


Script, Domain Model Table Module Transaction Script

Domain Model

Transaction
Script

Effort to
Enhanc
e

Table Module

Domain
Model

Complexity of Domain Logic

Pattern
Refactoring
Transaction
Script

Effort to
Enhance

Table Module

Domain Model

Refactoring

Complexity of Domain Logic

Transaction
Script

Transaction
Script

Effort to
Enhance

Change

Complexity of Domain Logic

Transaction
Script
Transaction
Script

Table Module

Effort to
Enhance

Change
Refactoring
Complexity of Domain Logic

--- ^^

PM

--- Extract Method


Step 1 :
JBuilder Code
Refactoring Extract Method

Step 2 : method OK

1 Pull Up Method
Transaction Script
methods
Transaction1
doSomeThing()

Transaction1

Transaction2

Transaction3

doSomeThing()

doSomeThing()

doSomeThing()

method

SuperTransaction
doSomeThing()

Transaction1

Transaction2

Transaction3

2 Push Down Method


methods
methods
(Push Down)

SuperTransaction
(from case1)

doSomeThing()
doSomeThingSpecial()

Transaction2

Transaction1

(from case1)

(from case1)

SuperTransaction
(from case1)

doSomeThing()

Transaction1
(from case1)

doSomeThingSpecial()

Transaction2
(from case1)

--- Class Class, Move Method


class class
class method ()
class (Move Method)
Class1

Class2

doSomeThing()

Class1

Class2
doSomeThing()

--- Package Package, Move Class


Package Class Package
(Move Class)

Package1

Package2

Package2

Package1

ClassA

ClassD
ClassC

ClassB
ClassE

Package2

Package1

ClassA

ClassC

ClassD

ClassB
ClassE


Refactoring
JBuidler

Try & Error

1. Refactoring Pattern
2. Open Source Project

Open Source Products


(Ex: Struts)
Pattern Pattern
OOSIG 4