锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲人成电影网站,国产亚洲美女精品久久久久狼,久久久久久a亚洲欧洲aⅴhttp://m.tkk7.com/jackybu/category/2315.html<a ><b><font color=red>鍏辨湁<script src=http://fastonlineusers.com/online.php?d=jackybu.blogjava.net></script>浜哄湪鍚屾椂闃呰姝log</font></b></a>zh-cnWed, 28 Feb 2007 07:48:05 GMTWed, 28 Feb 2007 07:48:05 GMT60TDD(3) --杞嚜http://m.tkk7.com/yandazhihttp://m.tkk7.com/jackybu/articles/8399.html杈?/dc:creator>杈?/author>Mon, 25 Jul 2005 04:28:00 GMThttp://m.tkk7.com/jackybu/articles/8399.htmlhttp://m.tkk7.com/jackybu/comments/8399.htmlhttp://m.tkk7.com/jackybu/articles/8399.html#Feedback0http://m.tkk7.com/jackybu/comments/commentRss/8399.htmlhttp://m.tkk7.com/jackybu/services/trackbacks/8399.html

鎰忓浘緙栫▼

programming by intention

鍚嶅瓧

Use nouns or noun phrases for class names

public class Movie {
  
//
}

public class MovieRatingComparator implements Comparator {
  
//
}

public class XMLMovieListReader implements MovieListReader {
  
//
}

Use either adjectives or generic nouns and noun phrases for interfaces

public interface Serializable {
}

public interface MovieListWriter {
  
void write(MovieList movieList) throws IOException;
}

Use verbs and verb phrases for method names


private int calculateAverageRating() {
  
int totalRating = calculateTotalRating();
  
return totalRating / ratings.size();
}


Use accepted conventions for accessors and mutators

public Category getCategory() {
  
return category;
}

public void setCategory(Category aCategory) {
  category 
= aCategory;
}

public boolean isOfCategory(Category aCategory) {
  
return category.equals(aCategory);
}

public boolean isRated() {
  
return !ratings.isEmpty();
}

public boolean hasRating() {
  
return !ratings.isEmpty();
}

public int size() {
  
return movies.size();
}


Don't put redundant information in method names

public void add(Movie movieToAdd) throws DuplicateMovieException {
  
if (this.contains(movieToAdd)) {
    
throw new DuplicateMovieException(movieToAdd.getName());
  }
  movies.add(movieToAdd);
}

There are always exceptions. Sometimes it is just clearer, and reads better, if you have type information in the method name.

public void addRating(Rating ratingToAdd) {
  ratings.add(ratingToAdd);
}

Use nouns and noun phrases for variable names.

public class Movie {
  
private String name = "";
  
private Category category = Category.UNCATEGORIZED;
  
private List ratings = null;

  
//
}


濡備綍鎰忓浘緙栫▼

鍖呮嫭浣跨敤闅愬柣錛屾祴璇曚紭鍏堬紝閲嶆瀯錛屼綔鍑哄亣瀹氾紝璁╃紪璇戝櫒鍛婅瘔浣犱笅涓姝ュ仛浠涔?榪欏嚑縐嶆妧宸с?BR>
鍏敤璇嶆眹琛?甯姪浣犵悊瑙h繖涓鍩熴?BR>                      甯姪浣犲彇鍚嶅瓧銆?BR>

"NO COMMENT"

Incomplete code

// TODO: The tree should be balanced after doing the insertion.
// CODE DEBT: the looping structure is a bit convoluted, could use
// some method extraction.


Refactoring doesn't make it clear enough

// NEEDS WORK: I tried extract method, but it's still awkward.
// Maybe refactoring to a Strategy would clean it up?


Use of an unusual algorithm

// I used an AVL Tree algorithm here to keep the tree balanced.


Use of a published algorithm

// This AVL alorithm was based on Brad Appleton's implementation at
// http://www.enteract.com/~bradapp/ftp/src/libs/C++/AvlTrees.html


Performance tuning

// A circular queue is used here for performance reasons: to avoid
// having to move elements around.


Class comment

/**
 * This class represents a single movie title. It is responsible for
 * maintaining its own ratings, reviews, etc.
 */



]]>
TDD(1)--杞嚜http://m.tkk7.com/yandazhihttp://m.tkk7.com/jackybu/articles/8397.html杈?/dc:creator>杈?/author>Mon, 25 Jul 2005 04:26:00 GMThttp://m.tkk7.com/jackybu/articles/8397.htmlhttp://m.tkk7.com/jackybu/comments/8397.htmlhttp://m.tkk7.com/jackybu/articles/8397.html#Feedback0http://m.tkk7.com/jackybu/comments/commentRss/8397.htmlhttp://m.tkk7.com/jackybu/services/trackbacks/8397.htmlTDD鏄繖鏍蜂竴縐嶈璁¢鏍?/FONT>

Maintain an exhaustive suite of Programmer Tests

緇存姢涓濂楃▼搴忓憳嫻嬭瘯鐨勬鏋?/P>

No code goes into production unless it has associated tests

闄ら潪瀹冨凡緇撳悎嫻嬭瘯錛屼駭鍝佷笉鍐欏叆浠諱綍浠g爜

Write the tests first

鍏堝啓嫻嬭瘯

Tests determine what code you need to write

嫻嬭瘯鍐沖畾浣犻渶瑕佸啓浠涔堜唬鐮?/P>

public void testEmptyList() {
    MovieList emptyList 
=newMovieList();
    assertEquals(
"Empty list should have size of 0"0, emptyList.size());
}



瑕侀氳繃涓婇潰鐨勬祴璇曪紝浣犲繀欏誨垱寤轟竴涓被MovieList錛屽拰涓涓柟娉晄ize();

錛坋clipse鐨?FONT size=2>蹇熶慨澶嶅姛鑳借兘甯綘鎼炲畾鍝︺傜湅鏉ュ厛鍐欐祴璇曡繕鏄緢鏂逛究鐨?^^*錛?BR>

璁╄綆楁満鏉ュ憡璇変綘

浣犻渶瑕佸鍔犵被鎴栬呮柟娉曪紝緙栬瘧鍣ㄤ細鍛婅瘔浣犮傦紙eclipse浼氬悜浣犳姳鎬ㄦ湁cannot be resolved 鐨勶級

涓嬮潰鐪嬬湅浠g爜鐨勬紨榪?BR>
public void testRating() {
  assertEquals(
"Bad average rating.",4,starWars.getAverageRating());
}



public void testRating() {
  starWars.addRating(
3);
  starWars.addRating(
5);
  assertEquals(
"Bad average rating.",4,starWars.getAverageRating());
}


public void testRating() {
  Movie starWars 
= new Movie("Star Wars");
  starWars.addRating(
3);
  starWars.addRating(
5);
  assertEquals(
"Bad average rating.",4,starWars.getAverageRating());
}



闈炲父鏈夋剰鎬濓紝鍜屾垜浠鉤鏃跺啓浠g爜鐨勯『搴忕浉鍙?BR>
涓嬮潰鐪嬬湅getAverageRating()錛?BR>
public int getAverageRating() {
  
return 4;
}


public int getAverageRating() {
  
return (3 + 5/ 2;
}



private int totalRating = 0;


public void addRating(int newRating) {
  totalRating 
+= newRating;
}




public int getAverageRating() {
  
return totalRating / 2;
}



private int numberOfRatings = 0;

public void addRating(int newRating) {
  totalRating 
+= newRating;
  numberOfRatings
++;
}


public int getAverageRating() {
  
return totalRating / numberOfRatings;
}



瀹為檯涓婏紝姣忔鍙樺寲涔嬪悗閮介噸鏂扮紪璇戝拰榪愯榪欎釜嫻嬭瘯銆?BR>

Agile Modeling and TDD


閲囩敤XP錛堟瀬闄愮紪紼嬶級鐨勯」鐩兘閲囩敤浜員DD鐨勮緟鍔╂墜孌點傚緩妯★紙modeling錛夋槸XP褰撲腑寰堥噸瑕佺殑鐨勪竴涓儴鍒嗐俋P寮鍙戣呬嬌鐢ㄧ敤鎴峰彊榪幫紙user stories錛?,鐢ㄦ埛鍙欒堪鏄竻鏅扮殑鏁忔嵎妯″瀷銆?BR>
鍒涘緩鏁忔嵎妯″瀷鑳藉甯姪鎴戜滑TDD宸ヤ綔錛岃繖鏄洜涓猴紝浠栬兘鎻ず鎴戜滑闇瑕佺殑嫻嬭瘯銆備竴涓晱鎹鋒ā鍨嬭崏鍥劇殑鑳屽悗鎬繪槸闅愬惈鐫榪欐牱鐨勬濊冣滄垜鎬庢牱鏉ユ祴璇曚粬鈥濓紝榪欏皢瀵艱嚧涓涓柊鐨勬祴璇曟渚嬨?BR>



]]>
TDD(2) --杞嚜http://m.tkk7.com/yandazhihttp://m.tkk7.com/jackybu/articles/8398.html杈?/dc:creator>杈?/author>Mon, 25 Jul 2005 04:26:00 GMThttp://m.tkk7.com/jackybu/articles/8398.htmlhttp://m.tkk7.com/jackybu/comments/8398.htmlhttp://m.tkk7.com/jackybu/articles/8398.html#Feedback0http://m.tkk7.com/jackybu/comments/commentRss/8398.htmlhttp://m.tkk7.com/jackybu/services/trackbacks/8398.html闃呰鍏ㄦ枃

]]>
TDD faqhttp://m.tkk7.com/jackybu/articles/8396.html杈?/dc:creator>杈?/author>Mon, 25 Jul 2005 04:23:00 GMThttp://m.tkk7.com/jackybu/articles/8396.htmlhttp://m.tkk7.com/jackybu/comments/8396.htmlhttp://m.tkk7.com/jackybu/articles/8396.html#Feedback0http://m.tkk7.com/jackybu/comments/commentRss/8396.htmlhttp://m.tkk7.com/jackybu/services/trackbacks/8396.html鍦═DD涓厧鐔簡宸叉湁涓闃靛瓙浜?鎵璋撳悆寰楄嫤涓嫤,鏂逛負浜轟笂浜?鍥為榪欐鏃呯▼,闇瑕佹葷粨鐨勪笢瑗垮緢澶?鎴戝彧鐞嗙悊鏇劇粡鍑虹幇鍦ㄨ剳嫻蜂腑鐨勭枒闂?騫舵彁渚涙湰浜虹殑瀵硅闂鐨勭悊瑙?浠ュ悗闅忔椂琛ュ厖.

鈽嗗啓嫻嬭瘯鐨勬椂闂存瘮鍐欎唬鐮佺殑鏃墮棿榪樺?

鍦ㄦ湁浜涙儏鍐典笅鐨勭‘濡傛,浣嗘槸涓嶈澶媴蹇?涓轟粈涔堝憿? 鏍規嵁鎴戠殑浣撲細:

1.鏈変簡嫻嬭瘯,浣犱細灝戝啓寰堝鏈潵涓嶉渶瑕?鍒濈湅璧鋒潵搴旇鏄湁鐢?鐨勪唬鐮?/P>

2.鍐欐祴璇曠殑榪囩▼灝辨槸鍦ㄨВ鍐抽棶棰樼殑榪囩▼,鍥犳浣犱細姣旇緝瀹規槗,灝芥棭鍦版槑鐧戒綘鍒板簳搴旇鍋氫粈涔?榪欐牱鍦ㄥ啓浠g爜鏃?灝辮兘鑺傜渷鏃墮棿

3.瀵歸噸鏋勫府鍔╁緢澶?鏈変簡嫻嬭瘯,浣犳墠鑳芥斁蹇冨ぇ鑳嗙殑榪涜閲嶆瀯.

4.闀胯繙鏉ョ湅,鍥犱負TDD浼氫績榪涗綘鍐欏嚭濂界殑浠g爜,騫朵笖浣犱細緇忓父鐨勯噸鏋?鍥犳浼氶檷浣庣淮鎶や唬浠?/P>

鈽嗛渶瑕佷負姣忎釜鏂規硶緙栧啓嫻嬭瘯鍚?

褰撶劧涓嶉渶瑕?鎴戜滑鎵鍐欑殑嫻嬭瘯蹇呴』鏄拡瀵規帴鍙f柟娉曠殑.涓鑸涓哄鐞嗕笟鍔¢昏緫鐨勬柟娉?浠ュ強棰嗗煙妯″瀷瀵硅薄鐨勫叧閿涓烘槸蹇呴』榪涜嫻嬭瘯. 鍏跺畠鐨勪竴浜涙柟娉曢渶瑕佽嚜宸辨妸鎻?褰撶劧榪欓渶瑕佺粡楠?

鎴戠幇鍦ㄥ彧鏄竴涓柊鎵?娌℃湁鍟ョ粡楠?鎴戝垽鏂煇涓柟娉曟槸鍚﹂渶瑕佹祴璇?渚濇嵁鏈変袱鏉?

1.鏄惁婊¤凍鎴戜笂闈㈠垪鍑虹殑蹇呴』嫻嬭瘯鏉′歡

2.鏄惁鍊肩殑嫻嬭瘯,榪欎竴鏉′富瑕佹槸蹇冪悊鍥犵礌,渚嬪瀵規煇涓柟娉曟劅瑙夊績閲屾病搴?閭e氨鍏堢紪鍐欐祴璇?

鈽員DD鏄竴縐嶆祴璇曟柊鎶鏈悧?

褰撶劧涓嶆槸,TDD鏍規湰灝變笉鏄竴欏規祴璇曟妧鏈?瀹冩槸涓縐嶆柊鐨勫紑鍙戞柟寮?鍙槸鍊熷姪嫻嬭瘯鑰屽凡.

鈽嗛」鐩竴寮濮嬫病鏈夐噰鐢═DD,鍦ㄩ」鐩腑鏈熷啀寮曞叆TDD,鍙鍚?

涓鑸潵璇翠笉鎺ㄨ崘鍦ㄩ」鐩腑鏈熷啀寮曞叆TDD,榪欐槸鐢變簬TDD鍐呭湪鐗規у喅瀹氱殑.

1.TDD鏄竴縐嶆柊鐨勫紑鍙戞柟娉?鍦ㄥ紑鍙戣繃紼嬩腑灝遍渶瑕佷綘杞彉鎬濇兂,闇瑕佸湪瀹炶返涓嶆柇瀹屽杽鑷繁,鑰屼笖瀹冩湰韜氨鍏鋒湁涓涓緝闄″涔犵殑鍧″害,榪欎竴鐐瑰湪寰堝鏂囩珷涓兘鎻愬埌榪?鍥犳鍦ㄩ」鐩腑鏈熷紩鍏DD,浼氱珛鍗蟲嫋寤墮」鐩繘灞?瀵歸」鐩湰韜府鍔╀篃涓嶄細澶ぇ.

2.TDD鍦ㄤ綘寮濮嬪啓嫻嬭瘯鏃?浼氶┍鍔ㄤ綘瀵歸棶棰樿繘琛屾濊?鐒跺悗鎸佺畫榪涜鍔熻兘澧炲己鍜岄噸鏋?鍦ㄩ」鐩腑鏈?濡傛灉浣犵紪鍐欎竴涓祴璇?榪欐椂浣犻渶瑕侀」鐩棭鏈熺殑涓涓粍浠?浣嗘槸榪欎釜緇勪歡騫舵病鏈夋弧瓚充綘鐨勬祴璇?鍥犱負鏍規湰灝辨病鏈夋祴璇?.鐜板湪鍥犱負璇ョ粍浠舵湁闂,嫻嬭瘯閫氫笉榪?濡傛灉榪欐椂浣犲啀涓鴻緇勪歡緙栧啓鍗曞厓嫻嬭瘯,灝卞け鍘諱簡嫻嬭瘯椹卞姩寮鍙戠殑浼樺娍浜?姝ゆ椂TDD鐨勬晥鏋滃氨澶ф墦鎶樻墸浜?

褰撶劧,鍦ㄦ病鏈夐」鐩帇鍔涚殑鎯呭喌涓?寮曞叆TDD鏄病鏈変換浣曢棶棰樼殑.涓嶈繃鎴戣繕鏄帹鑽愬湪欏圭洰寮濮嬪氨寮曞叆TDD鏄渶浣抽夋嫨.

鈽嗕負涔熷瓨鍦ㄧ殑緇勪歡琛ュ厖鍗曞厓嫻嬭瘯鍊煎緱鍚?

鍦ㄤ笂涓闂鐨勭浜岀偣鍘熷洜涓凡緇忔彁鍒拌繃,鎰熻涓嶅煎緱.鍦ㄨ繖縐嶆儏鍐典笅,鐢ㄤ竴鑸殑鏂規硶嫻嬭瘯涓涓嬪嵆鍙?姣斿java鐨刴ain()鏂規硶.

鈽員DD緙栧啓鐨勬祴璇曟渚嬫槸姣旇緝澶嶆潅鐨勫悧?

鍦═DD涓?嫻嬭瘯鏄竴姝ヤ竴姝ユ紨鍖栫殑,闇瑕佷綘涓鐩翠繚鎸佺畝鍗曡璁$殑鐞嗗康,鍥犳,涓鑸祴璇曟渚嬫槸姣旇緝娓呮櫚鐨?濡傛灉鍙戠幇浣犵殑嫻嬭瘯闈炲父澶嶆潅,搴旇鏄綘娌℃湁鎶撲綇闂鐨勯噸鐐規垨鑰呮病鏈夋帉鎻℃紜?鏈夋晥鐨勬柟娉?



]]>
Test-Driven Developmenthttp://m.tkk7.com/jackybu/articles/8395.html杈?/dc:creator>杈?/author>Mon, 25 Jul 2005 04:22:00 GMThttp://m.tkk7.com/jackybu/articles/8395.htmlhttp://m.tkk7.com/jackybu/comments/8395.htmlhttp://m.tkk7.com/jackybu/articles/8395.html#Feedback0http://m.tkk7.com/jackybu/comments/commentRss/8395.htmlhttp://m.tkk7.com/jackybu/services/trackbacks/8395.html

 

Test-Driven Development

http://www.xprogramming.com/xpmag/whatisxp.htm#test

Extreme Programming is obsessed with feedback, and in software development, good feedback requires good testing. Top XP teams practice "test-driven development", working in very short cycles of adding a test, then making it work. Almost effortlessly, teams produce code with nearly 100 percent test coverage, which is a great step forward in most shops. (If your programmers are already doing even more sophisticated testing, more power to you. Keep it up, it can only help!)

It isn't enough to write tests: you have to run them. Here, too, Extreme Programming is extreme. These "programmer tests", or "unit tests" are all collected together, and every time any programmer releases any code to the repository (and pairs typically release twice a day or more), every single one of the programmer tests must run correctly. One hundred percent, all the time! This means that programmers get immediate feedback on how they're doing. Additionally, these tests provide invaluable support as the software design is improved.

鍦ㄤ笂闈㈢殑鍥句腑錛屽垪鍑虹殑鐨勬槸XP鐨?2涓洟闃熷疄璺點俆est-Driven Development鏄叾涓箣涓銆?/DIV>
Kent Beck 鐨勮憲浣淭DD(Test Driven Development) 涓緇嗚榪頒簡嫻嬭瘯椹卞姩寮鍙戙?/DIV>
鍦╔P涓祴璇曟槸涓縐嶈璁★紝涓嶆槸綆鍗曠殑涓轟簡嫻嬭瘯浣犵殑鍔熻兘鏄惁瀹炵幇銆傛祴璇曞厛琛屼竴涓洰鐨?/DIV>
鏄彲浠ュ湪浠g爜緙栧啓涔嬪墠錛屼繚璇佹祴璇曞凡緇忓啓濂斤紱鍏跺疄榪欎簺嫻嬭瘯鐨勫彟涓涓洰鐨勫氨鏄璁℃帴鍙o紝
淇濊瘉鎺ュ彛鍦ㄤ互鍚庣殑淇敼榪囩▼涓兘澶熸弧瓚蟲祴璇曪紙璁捐錛夈?EM>褰撲綘鏈夋剰鎴栨棤鎰忎慨鏀規帴鍙g殑鏃跺欙紝浣犲繀欏誨悓鏃?/FONT>
淇敼嫻嬭瘯 瑕佹敼鍔ㄦ帴鍙g殑鏃跺欙紝涔熷簲璇ユ槸鍏堜慨鏀規祴璇曪紝鍐嶄慨鏀逛唬鐮併傝屼笉鏄慨鏀逛唬鐮佺瓑鐫鎶ラ敊鍐嶄慨鏀?/FONT>
嫻嬭瘯(璁捐錛?/FONT>銆傦紙嫻嬭瘯蹇呴』100%閫氳繃鎵嶈兘榪涜涓嬩竴涓姛鑳斤級錛岃繖鏍鋒祴璇曚篃鏄湪鎻愰啋浣狅紝鎺ュ彛宸茬粡鏀瑰彉銆?/FONT>
瀹為檯涓婏紝璁捐宸茬粡鏀瑰彉銆傚綋浣犱慨鏀瑰崟鍏冩祴璇曠殑鏃跺欙紝鍙兘灝變細閬埌鎶辨ㄣ備負浠涔堬紵浣犱慨鏀逛簡璁捐
錛屽埆浜虹殑浠g爜鏄緷璧栦綘淇敼鍓嶇殑嫻嬭瘯錛堣璁★級錛岄偅涔堟柊鐨勬祴璇曪紙璁捐錛変腑鐨勫彉鍔ㄥ彲鑳借褰卞搷鍒?/DIV>
鍒漢宸叉湁鐨勪唬鐮併?/DIV>
 
褰撲綘浣跨敤TDD鐨勬椂鍊欎竴瀹氳璇存槑鏄祴璇曢┍鍔ㄥ紑鍙戣繕鏄祴璇曢┍鍔ㄨ璁°傝繖涓よ呮槸鏈夊尯鍒殑銆傛祴璇曢┍鍔?/DIV>
寮鍙戯紝鏄氳繃嫻嬭瘯瀹氫箟鎵瑕佸紑鍙戠殑鍔熻兘鐨勬帴鍙o紝鐒跺悗瀹炵幇鍔熻兘鐨勫紑鍙戣繃紼嬨傚浜庢祴璇曢┍鍔ㄨ璁★紝鍦╔P涓技涔?/DIV>
宸茬粡娑堝け浜嗭紝鑰屾槸琚祴璇曢┍鍔ㄥ紑鍙戞墍鍙栦唬銆傚彟澶栧湪XP涓湁鐢ㄤ簬鎻忚堪璁捐鐨勶紝SimpleDesign 錛孌esign Improvement.
鍦╔P涓祴璇曟槸涓縐嶈璁★紝璁捐涔嬪悗鎵嶆湁寮鍙戯紝榪欎篃灝辨槸涓轟粈涔堣嫻嬭瘯鍏堣浜嗐?/DIV>
鍦╔P涓祴璇曟槸涓縐嶆枃妗o紝鐢ㄤ簬鎻忚堪璁捐銆?/DIV>


]]> 主站蜘蛛池模板: 成人免费无遮挡无码黄漫视频| 久草在视频免费福利| 污视频网站在线免费看| 亚洲AV无码之国产精品| 亚洲国产aⅴ成人精品无吗| 亚洲色欲啪啪久久WWW综合网| 国产jizzjizz视频免费看| 最近中文字幕mv手机免费高清| www在线观看免费视频| 一本到卡二卡三卡免费高 | 三年在线观看免费观看完整版中文 | aa在线免费观看| fc2免费人成在线视频| 久久久精品视频免费观看 | 久久亚洲国产午夜精品理论片| 在线观看视频免费国语| 毛片免费vip会员在线看| 色天使亚洲综合在线观看| 羞羞视频免费网站含羞草| 亚洲国产成人久久精品大牛影视 | 亚洲欭美日韩颜射在线二| 好爽好紧好大的免费视频国产| 国产一区二区三区在线免费| 毛片网站免费在线观看| 亚洲免费在线观看视频| 无码人妻一区二区三区免费手机| 国产桃色在线成免费视频| 亚洲AV无码一区二区三区鸳鸯影院| 99re免费视频| 妻子5免费完整高清电视| 国产亚洲综合久久| 一级全免费视频播放| 亚洲电影中文字幕| 亚洲AV无码专区国产乱码4SE| 成人一a毛片免费视频| 国产成人免费福利网站| 78成人精品电影在线播放日韩精品电影一区亚洲 | 99在线观看精品免费99| 欧洲精品99毛片免费高清观看| 国产一级黄片儿免费看| 亚洲片一区二区三区|