锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲AV无码乱码国产麻豆,亚洲成AV人片在线观看无码,亚洲狠狠婷婷综合久久久久http://www.tkk7.com/chaocai/category/45371.htmlzh-cnSun, 05 Aug 2012 21:12:00 GMTSun, 05 Aug 2012 21:12:00 GMT60The Clojure Program To solve N Queens Problemhttp://www.tkk7.com/chaocai/archive/2012/08/05/384844.html瓚呰秺宸呭嘲瓚呰秺宸呭嘲Sun, 05 Aug 2012 15:26:00 GMThttp://www.tkk7.com/chaocai/archive/2012/08/05/384844.htmlhttp://www.tkk7.com/chaocai/comments/384844.htmlhttp://www.tkk7.com/chaocai/archive/2012/08/05/384844.html#Feedback0http://www.tkk7.com/chaocai/comments/commentRss/384844.htmlhttp://www.tkk7.com/chaocai/services/trackbacks/384844.htmlThe following program is about solving N-Queens problem (http://en.wikipedia.org/wiki/Eight_queens_puzzle) by Clojure. If you have the better solution in Clojure or Haskell, welcome to provide your solution.
(ns queens)
(defn conflictInRow? [queens newqueen]
  (some #(= newqueen %) queens)
)
(defn conflictInDia? [queens newqueen]
  (let [dia (count queens) 
        n1 (fn [queen] (Math/abs (- dia (.indexOf queens queen))))
        n2 (fn [queen] (Math/abs (- newqueen queen)))]
    (some #(= (n1 %) (n2 %)) queens)
   )
 )
(defn conflict? [queens newqueen]
  (or (conflictInRow? queens newqueen) (conflictInDia? queens newqueen))
 )
(def cnt (atom 0))
(defn put-queens [queens newqueen boardSize ]
  (if (= (count queens) boardSize)  
    (do
      (println queens)
      (reset! cnt (inc @cnt))
    )
    (do 
      ;(println queens)
      (if (> newqueen boardSize)
     
           (if (and (= (peek queens) boardSize) (= (count queens) 1))
               (throw (Exception. (str "That's all " @cnt)))
               (recur (pop queens) (inc (peek queens)) boardSize )
           )
     
        (if (conflict? queens newqueen)
            
             (recur queens (inc newqueen) boardSize )
             
          (do
             (put-queens (conj queens newqueen) 1 boardSize )
             (recur queens (inc newqueen) boardSize )
           )
        )
       )
      )
    )
    
)
(defn queens [boardSize] 
    (put-queens [] 1 boardSize)
 )


Chao Cai (钄¤秴錛?/div>

Sr. Software Dev Engineer 
Amazon.com

 


]]>TDD Tipshttp://www.tkk7.com/chaocai/archive/2011/01/09/342623.html瓚呰秺宸呭嘲瓚呰秺宸呭嘲Sun, 09 Jan 2011 08:55:00 GMThttp://www.tkk7.com/chaocai/archive/2011/01/09/342623.htmlhttp://www.tkk7.com/chaocai/comments/342623.htmlhttp://www.tkk7.com/chaocai/archive/2011/01/09/342623.html#Feedback1http://www.tkk7.com/chaocai/comments/commentRss/342623.htmlhttp://www.tkk7.com/chaocai/services/trackbacks/342623.htmlHow to design the testable software? You may always find some best practices about designing for scalable, extensible or maintainable. To be testable, the best way should be TDD. Followings are some tips from my real practices on TDD.

1 TDD is design process; it let you design for testing, naturally

Write the test firstly, it does not only help you find the bugs; but the most important point is to let you design for test naturally.

Also you should keep in mind, tests not only help you find bugs, but also protect your codes; when some changes impact on your existing codes, the tests will be broken.

 

2 Keep the implementation simple

Keep your implementation simple, just let the test pass. The complex implementation may introduce the logics or codes not covered by the tests, even leads some codes not testable.

 

3 TDD in each scope.

You may get to know the concept ATDD (acceptance test driven development). TDD could be used in every phase of the development and by the different granularity.

To ATDD, you could consider on using some existing framework such as FIT, these frameworks will be bridge between business logic and implementation logic.

Recently, the concept BDD (behavior driven development) is introduced to the ATDD process, so the BDD frameworks such as JBehave is also the good choice.

 


Different TDD process could be nested and should be nested don’t let your step too large.

 

4 keep each step small enough

Always keep each step small to avoid introducing the untestable codes or logics and pass each test quickly.

 

 

6 Always refactor

This step is always overlooked in TDD process; however it is the very important step. Also, never forget refactor should involve all your tests.

 

Why can't write test firstly?

 1.not think how to meature the codes

2. The current step maybe too large, should separate into small ones

3. The codes with ugly dependencies


 http://blog.csdn.net/chaocai2004/archive/2011/01/09/6125479.aspx


Chao Cai (钄¤秴)

Sr. SDE

Amazon.com

 



]]>
綆楁硶鐨勬椂闂村鏉傚害http://www.tkk7.com/chaocai/archive/2010/06/18/323815.html瓚呰秺宸呭嘲瓚呰秺宸呭嘲Fri, 18 Jun 2010 07:26:00 GMThttp://www.tkk7.com/chaocai/archive/2010/06/18/323815.htmlhttp://www.tkk7.com/chaocai/comments/323815.htmlhttp://www.tkk7.com/chaocai/archive/2010/06/18/323815.html#Feedback1http://www.tkk7.com/chaocai/comments/commentRss/323815.htmlhttp://www.tkk7.com/chaocai/services/trackbacks/323815.html鐩鎬俊澶у瀵逛簬綆楁硶鐨勬椂闂村鏉傚害O閮戒笉浼氶檶鐢燂紝涓嶈繃浣犵煡閬撲竴涓畻娉曠殑鏃墮棿澶嶆潅搴︽槸濡備綍璁$畻鍑烘潵鐨勫悧錛?/span>

浠ュ墠鍦ㄥ涔犵畻娉曞拰鏁版嵁緇撴瀯鐨勬椂鍊欙紝瀵逛簬姣忕綆楁硶鐨勫鏉傚害閮芥槸姝昏鐨勫茍娌℃湁鐪熸鐨勫幓鐮旂┒浠栦滑鏄浣曡綆楀嚭鏉ワ紝鏈榪戠獊鐒跺綆楁硶浜х敓浜嗗叴瓚o紝榪嬌鑷繁鐮旂┒浜嗕竴涓嬬畻娉曞鏉傚害鐨勮綆楁柟娉曘?/span>

姒傚康

澶?/span>O琛ㄧず娉曡〃紺烘椂闂村鏉傛э紝娉ㄦ剰瀹冩槸鏌愪竴涓畻娉曠殑鏃墮棿澶嶆潅鎬с傚ぇO琛ㄧず鍙槸璇存湁涓婄晫錛岀敱瀹氫箟濡傛灉f(n)=O(n)錛岄偅鏄劇劧鎴愮珛f(n)=O(n^2)錛屽畠緇欎綘涓涓笂鐣岋紝浣嗗茍涓嶆槸涓婄‘鐣岋紝浣嗕漢浠湪琛ㄧず鐨勬椂鍊欎竴鑸兘涔犳儻琛ㄧず鍓嶈?/span>銆?/span>

鍙﹀闄や簡榪欎釜瀹樻柟姒傚康錛屼釜浜鴻涓哄ぇO琛ㄧず鐨勬槸闂瑙勬ān鍜岀畻娉曚腑璇彞鎵ц嬈℃暟鐨勫叧緋匯?/span>

浠ヤ簩鍒嗘煡鎵句負渚嬶紝鎴戜滑姹傝В瀹冪殑鏃墮棿澶嶆潅搴?/span>

1 璁捐妯′負n涓厓绱犳椂錛岃鎵цT(n)嬈?/span>

T(n)=T(n/2)+1

T(n)=[T(n/4)+1]+1

T(n)=T(n/2^m)+m

褰?/span>n=2^m

T(n)=T(1)+log2n

T(1)=1

鎵浠ュ叾綆楁硶澶嶆潅搴︿負O錛坙og2n錛?/span>



]]>
主站蜘蛛池模板: 亚洲av无码专区在线播放| 亚洲国产成人影院播放| 老司机亚洲精品影院| 久久免费香蕉视频| 黑人精品videos亚洲人| 一级日本高清视频免费观看| 亚洲av麻豆aⅴ无码电影| 免费播放美女一级毛片| 亚洲AV无码乱码在线观看性色扶| 香港经典a毛片免费观看看| 亚洲AV无码乱码在线观看| av电影在线免费看| 国精无码欧精品亚洲一区| 亚在线观看免费视频入口| 亚洲AV日韩AV天堂一区二区三区| 免费无码又爽又刺激高潮视频| 亚洲高清资源在线观看| 成年女人免费v片| 亚洲成a人片在线不卡一二三区| 免费一级成人毛片| 国产免费无码一区二区| 337p日本欧洲亚洲大胆精品555588| 91免费国产在线观看| AV激情亚洲男人的天堂国语| 超清首页国产亚洲丝袜| 免费h视频在线观看| 性xxxx黑人与亚洲| 亚洲国产成人久久综合碰| a毛片免费在线观看| 亚洲国产成人99精品激情在线 | 无码av免费一区二区三区试看| 中文字幕亚洲综合久久| 国产精品免费一级在线观看| 乱人伦中文视频在线观看免费| 亚洲Av永久无码精品三区在线| 久草视频在线免费| 日韩精品视频在线观看免费| 久久国产亚洲高清观看| 日韩免费视频网站| 午夜理伦剧场免费| 午夜在线亚洲男人午在线|