| | | |

g?XP
Joshua KerievskyGigix ?20020514

g????XP?o??ý?I??XP??refactoringg?????????ôg?XPk?õ???XP?g?'öøá

?

??Kent BeckMartin FowlerWard Cunningham????

????'??g??????J??????t???õ?????????J????????????hµ????j??j??

j?S?????over-engineer???J???????????U?o??û??????????ô?L?û???

????h????j??h?j???DD?õlDD?????i?û??i?????'??'???

????ô?XP????????ô?XP?õ??¡????Kent Beck?

?h????l????õL¸?o[Beck1 00]

??????Norm KerthNorm??l??hjXP?ô??

?XPÿ?j??ôXP?[Kerth 99]

???Normhg???XP??l'g?l?h?XPJ'?g?tûh??g??XP

h'?û??????????

????XPg??ltXP?g??øã?XPg??XP??øá

?h????'g?XPh??'

1995?'?'g?????g??hÿheg????'g???UPh'g?L??????g??h???

??h??g?hh?'??h£?????û?h???'???

1996??h????'???????g???????

???_?DDg??LDD?h??

???????[GHJV1 95]

g???L??ô????g????????a?????ÿh????æ

????????ô??'??h?????h??¼JAVA?

???

??L??hI??????'h????h????'h????'?????????go???????h????h'K????????h?????h???h???µL??????[Kerievsky 96]

?????????g'g?k?'i????'g?????g?????h??h??'???g???'??????????????

'g?·h?õk????????

??XP?????'h???XP?ô?XP???g??????h?h??h???

ôg?ô?

?hJ?g?????

???h??DDh?Martin FowlerL??????h???g??g????õ???XPô?g??

?jPortland Pattern Repository?????XPg????g?????????ô??j?Ron Jeffries?XP????

h???L???g?h??õJ???£J???õJ?

hDD??h?DD??g????BeckSmalltalk Best Practice Patterns???????g?g??û??g????????Martin Fowlerl?kg???S???h?g???gL[Jeffries 99]

h??Lg?L???g?????'ãRon??S?g???L?Ron?h?h??g???'?

????DDXPDDh???'?g?L?'?g?'ôg

????'g?????g??'??hg?L?????g??g?????k??????'??????g?h??

g????????g?g????j????g???????????'?g?'ôg?õ??

û?g???????Ron?'g?k????gDD?????g?h???g????h??g?????????g?

???g??g???h?g?'?????L??g????g???J???g??ôg?

ô??h?g?'?????g???????'???S??

?'g?h?

??g???ã?'??Yg????????õg

ôXPg??I???

???'g????g?XP??

???g???h¡g??ôh???????

?g?¼????'?g?????'????'?g??????g??????[GHJV2 95]

?L??????g???'g?L???'g??????g???g??U???g?

?????L??õ?XPõ??

;???'g???ok??

??S?û???'???????????????'g?ÿ??

Kent Beck?Lg???[Beck2 94]

g????'á??'??????????????g?j?g?g?ã

?'?g?????

hš???hg?Lô????o

hS?h???h?g???

??????õl?

h?????YJAVA????h?L???û?JAVA???????e????gô??

???h???Commandg??h??L???????û???????????

úCommandg???L??????'Commandg????'?h'Commandg?

h???????óWEB?ó?Builderg??????áû????hô??oBuilderg?þ?????????g

??'?g?h'??ð?'?????????L?g?????

h?h?

??ö??J??g???'?hh??h'?û????š??'????I??¿?????û???????û???k?

ø??k?????ÿ??hl??30??h???l?h±??

XP?'g?±??û????LDD???lDD??

???g??L??g

?????h¾???????????????????Ž????·??????L??o

g????j??

????g?ã??o?g???¹?

???'g?kJ??g?'???o??K?

??'g???g?'??????h??L??

JUnith??õJAVA??Kent BeckErich Gammah???l??g?

h???JUnitDeGoF??JUnit?g????ûg?JUnit?ô?h?????ò???ô???g?

??K?JUnit 2.1?h??DeGoF

JUnithTestCase???l?TestCaseû????k?û?????kErichKentDecoratorg?w?????????Y??Decoratorg??????ôh????

Test CaseJUnit1.0?????????????

public abstract class TestCase implements Test {
private String fName;
public TestCase(String name) {

fName= name;

}

public void run(TestResult result) {

result.startTest(this);

setUp();

try {

runTest();

}

catch (AssertionFailedError e) {

result.addFailure(this, e);

}

catch (Throwable e) {

result.addError(this, e);

}

tearDown();

result.endTest(this);

}

public TestResult run() {

TestResult result= defaultResult();

run(result);

return result;

}

protected void runTest() throws Throwable {

Method runMethod= null;

try {

runMethod= getClass().getMethod(fName, new Class[0]);

} catch (NoSuchMethodException e) {

e.fillInStackTrace();

throw e;

}

try {

runMethod.invoke(this, new Class[0]);

}

catch (InvocationTargetException e) {

e.fillInStackTrace();

throw e.getTargetException();

}

catch (IllegalAccessException e) {

e.fillInStackTrace();

throw e;

}

}

public int countTestCases() {

return 1;

}

}

µ?????????

û?????????TestCase???h?????????????ø?

h????L??TestCase??DD??g???DD'???????????j?J????

public abstract class TestCase implements Test {
private String fName;
private int fRepeatTimes;
public TestCase(String name) {
this(name, 0);
}
public TestCase(String name, int repeatTimes) {
fName = name;
fRepeatTimes = repeatTimes;
}
public void run(TestResult result) {
for (int i=0; i < fRepeatTimes; i++) {
result.startTest(this);
setUp();
try {
runTest();
}
catch (AssertionFailedError e) {
result.addFailure(this, e);
}
catch (Throwable e) {
result.addError(this, e);
}
tearDown();
result.endTest(this);
}
}
public int countTestCases() {
return fRepeatTimes;
}
}

?runTestResult resulth???TestCaseL??j????ô¡?????ô'Decoratorg??g

??ÿTestCase????h???

public abstract class TestCase implements Test {
private String fName;
private int fRepeatTimes;
private boolean fThreaded;
public TestCase(String name) {
this(name, 0, false);
}
public TestCase(String name, int repeatTimes) {
this(name, repeatTimes, false);
}
public TestCase(String name, int repeatTimes, boolean threaded) {
fName = name;
fRepeatTimes = repeatTimes;
fThreaded = threaded;
}
public void run(TestResult result) {
if (fThreaded) {
final TestResult finalResult= result;
final Test thisTest = this;
Thread t= new Thread() {
public void run() {
for (int i=0; i < fRepeatTimes; i++) {
finalResult.startTest(thisTest);
setUp();
try {
runTest();
}
catch (AssertionFailedError e) {
finalResult.addFailure(thisTest, e);
}
catch (Throwable e) {
finalResult.addError(thisTest, e);
}
tearDown();
finalResult.endTest(thisTest);
}
}
};
t.start();
result = finalResult;
} else {
for (int i=0; i < fRepeatTimes; i++) {
result.startTest(this);
setUp();
try {
runTest();
}
catch (AssertionFailedError e) {
result.addFailure(this, e);
}
catch (Throwable e) {
result.addError(this, e);
}
tearDown();
result.endTest(this);
}
}
}
public int countTestCases() {
return fRepeatTimes;
}
}

?'ø???µ??runTestResult resultJ???

'?´???û??????????g??J????Zg

???????????hµ?ô?JUnit 3.1???TestCase????L???JUnit????DDû??J??TestCasel??û????TestCase?µ?????

hg?????????DD?g?????

'g?????'g?l??S?g???g????????I?j?g?

?g???k?'?g?õIDD??k?XPk?XPk?'g???l????g??'ù?g??g?????g?l??????

XP??g??ã?g?'?XP???

??

[Beck1 00] Beck, Kent. Email on extremeprogramming@egroups.com, January 2000.

[Beck2 94] Patterns Generate Architectures, Kent Beck and Ralph Johnson, ECOOP 94

[GHJV1 95] Design Patterns: Elements of Reusable Object-Oriented Software, by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. ?g??L??

[GHJV2 95] Design Patterns: Elements of Reusable Object-Oriented Software, by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. Pages 353-354 ?g??L??6¡

[Jeffries 99] Jeffries, Ron. Patterns And Extreme Programming. Portland Pattern Repository. December, 1999

[Kerth 99] Kerth, Norm. Conversation, circa March, 1999.

[Kerievsky 96] Kerievsky, Joshua. Dont Distinguish Between Classes And Interfaces. Portland Pattern Repository. Circa 1996

 <>

? | ? | | ? | ? | | | ? | ? | ??

Copyright® 2003 Test Engineer, Inc. All rights reserved.

 

| | | Level-2 Key Process Area | Level-2 Evaluation | Activities Performed for | IV&V Definition | Comparing SQA and IV&V | Success Stories | Software Quality Metrics | Determination of Metrics | Example Measures | Example Measures (cont.) | Defect Measurement | Change Activity | PPT Slide | PPT Slide | PPT Slide | PPT Slide | PPT Slide | PPT Slide | PPT Slide | PPT Slide | ArrayArrayArrayArrayReisen Bis 200 Euro - Kredyty Mieszkaniowe - Kredyty - Tech NewsArrayArrayArrayArray