I'm CaLendarW Blog

Archive for April, 2009

Acceptance Test Driven Development

by on Apr.30, 2009, under requirement, testing

Last night, I went to join the meeting of Agile Hong Kong, the topic is Acceptance Test-Driven Development(ATDD), presented by Steven Mark, which look-like great, user friendly, and example-driven concept to improve the software quality and meet the customer expectation, the different between TDD and ATDD is that the TDD is more focus on unit testing, test case written by developer and ATDD is focus on the customer example, test case written by user in readable format, one of practice is customer/business analyst provide html “table” of example using wiki and let the FIT or Robot framework read the html “table” and provide test result.

ATDD is great, but currently I still need a time to pickup the current unit testing with NUnit, lack of experience and no partnership in agile development is my weakness, and I need more time to train up my experience. I hope that I have opportunity to apply agile in future although current environment seen doesn’t permit.

Another good thing in this meeting is meeting with Rex, who is the Ruby developer and IT company owner, we have similar idea of Hong Kong IT Event Calendar before and he did better than me. Also, in this meeting, free pizza was good, and small gift (should be the score card) was offered.

Leave a Comment :, more...

Rebuild Index on MsSQL

by on Apr.28, 2009, under database

今日要對現有既 Table 做 Performance Testing, 但因為要 join 太多既 Table, 搜尋一個要 join 4 個 Table 先拎到想要既 “一隻” Record 既時間竟然要 11 秒, 可想而知個 Table Size 有幾大吧 (其實七位數字既 Record Count 啫, 而 where case 只有兩個用 ‘=’ 既 criteria, 而且所有 Record 只能 insert, 不能 delete).

經過我 rebuild 過接近 10 個已有既 index 之後 (等了好幾分鐘), 搜尋時間減少至只需 5 秒…

以下係 mssql 2005 下 rebuild index 既一個 statement 既例子

ALTER INDEX IX_tblMaster ON tblMaster REBUILD;

IX_tblMaster 係 index 名
tblMaster 係 table 名

Leave a Comment :, more...

交通路線搜尋服務

by on Apr.28, 2009, under diary, web

今日政府推出左個交通路線搜尋服務, 總算係多左舊野……用過一陣, 感覺真的很 “不該”……

  1. ASP.NET 都出度 3.5, 而且又有 Ajax 版本及 MVC Framework, 但網站竟然仲用緊最傳統既 Active Server Page.
  2. 網站介面 menu d CSS 去到 Firefox 就走左位, 而且仲係用緊 tr, 就連 HKEPC 都識得用 li + CSS 黎做 menu, 唉… 不過都仲識用返少少 CSS, 唔係全部都 embed 晒 d format 入去.
  3. Web 2.0 都出左咁耐, 人地流行用 beta 字樣, 但佢用 “Pilot Version”, 都唔知搞乜.
  4. 因為用 iframe 既關係, 搜尋結果 bookmark 不能.
  5. 速度方面, 好慢…
  6. 另外, 唔明點解唔用地政總處有份既中原地圖, 資源得不到善用.
  7. For mobile 方面, 未發現有 PDA 版, 可能覺得出左街既人就會識路掛…

其他安全性測試就因未有時間而唔去搞住啦, 希望正式版有更多改變啦.

Leave a Comment : more...

Sqlcmd

by on Apr.27, 2009, under database

Project Development Phase 已經開始, 但因為部份 Design 未全面, 所以仲有好多 Drop Table, Create Table 及 Initialize Value 既動作要做, 因為係咁, 所以就上網搵左點樣在 command prompt 行 SQL file.

Usage: Sqlcmd [-U login id] [-P password] [-S server] [-H hostname] [-E trusted connection] [-d use database name] [-l login timeout] [-t query timeout] [-h headers] [-s colseparator] [-w screen width] [-a packetsize] [-e echo input] [-I Enable Quoted Identifiers] [-c cmdend] [-L list servers[clean output]] [-q "cmdline query"] [-Q "cmdline query" and exit] [-m errorlevel] [-V severitylevel] [-W remove trailing spaces] [-u unicode output] [-r[0|1] msgs to stderr] [-i inputfile] [-o outputfile] [-z new password] [-f | i:[,o:]] [-Z new password and exit] [-k[1|2] remove[replace] control characters] [-y variable length type display width] [-Y fixed length type display width] [-p[1] print statistics[colon format]] [-R use client regional setting] [-b On error batch abort] [-v var = "value"...] [-A dedicated admin connection] [-X[1] disable commands, startup script, environment variables [and exit]] [-x disable variable substitution] [-? show syntax summary]

而自己就寫左個 batch 係 rebuild database:

sqlcmd -U calendarw -P password -S 192.168.1.10 -d testing_database -i Drop_Table.sql
sqlcmd -U calendarw -P password -S 192.168.1.10 -d testing_database -i Create_Table.sql
sqlcmd -U calendarw -P password -S 192.168.1.10 -d testing_database -i Init_Default_Value.sql
Leave a Comment : more...

Separation Of Concerns

by on Apr.26, 2009, under architecture, design

係軟件設計方面, 其實主要都想將唔同既 Concern 分開, 以我做開主要有以下幾個:

  • Flow / Business Logic
  • Input (Import Data, Interface for 3rd Party)
  • Output (User Interface, Report)
  • Database
  • Logging
  • Permission

在以上幾個 Concern 上, 而 Logging 同 Permission 呢兩樣野其實應該可以重用, 而且應該可以視為另一個軟件 / Domain Area.

Database 使用方面, 因為市面有不同種類既選擇, 而為左可以應用係唔同 Database 上, 好多人都會加上一個 Data Access Layer, 正常既 implement 手法都係 Object Relational Mapping, 在 .net 主要有 LGPL LicenseNHibernate, Castle Project 既Active Record, 又或者係 .net 3.5 既 Linq To SQLEntity Framework, 這些 Module 已經被外國引用成為主流, 因為使用者不用因應不同既 Database 而寫大同小異既 SQL, 避免了因小異而不段尋找問題, 只要學習一套, 其他由 OR Mapper 做便好了.

Logging 方面, Debug Log 其實可以用 Apache Licenselog4net, 而 Audit Log 我覺得應該可以視為另一個軟件而寫到一個 Lib 黎比全公司用, 以統一全公司軟件開發基礎.

Permission 方面主要有 AuthenticationAuthorization 兩個部份, 我覺得可以寫得開一個 Lib, 因應唔同需要 (e.g. 用 AD or 自己既 Login Table) 而各自使用同一個 Interface 既唔同 Implementation, 總好過不同 Project 都用緊不同既處理手法.

Input 同 Output 方面其實都幾難重用, 不過都應該可以寫到一 d 相對應既 Lib (e.g. Import/Export Excel, Customize User Control 或者既定的 3rd Party Solution).

Flow 其實係最難重用既部份, 因為應該唔同 Project 都有唔同既 Flow / Business Logic, 而常見既處理手法都會使用 Object Oriented Design, 而為了保證質素, 外國 (包括 Microsoft) 寫左套測試系統黎令做 Automate Testing, 有早期自己用開既 NUnit, 或者 Visual Studio 2005 打後既 Unit Testing Framework, 當然仲有好多其他既 Implementation, 只不過自己用開 NUnit 而無再留意.

綜合以上不同既 Concern, 其實除左 Flow/Business Logic, Input 同 Output 之外, 其他部份應該都可以重用, 如果每個 Project 都可以重用這些 Module, 寫軟件既時間應該可以集中一點在不能重用既部份而提高用家對軟件質素既評價, 亦可以有時間做 Performance Turning 及 Unit Testing, 使軟件能夠提升質量, 有關點解要 Testing 既資料可以參考舊 Post, 而 Performance Testing 其實亦可以靠 Unit Test 黎做監察 (詳見 Pragmatic Unit Testing in C# with NUnit 內有關 Performance Testing 一節)

重用既除左可以減少需要 Implement 既時間外, 對新人黎講都會容易跟, 因為套套系統都用緊同一樣野可以減省 Pickup 現有系統既時間. 不過對於重用方面, 公司既軟件管理政策亦同樣重要, 如果個個 Project 都係 Copy 一套出黎用, 那麼發現一個 Bug 就要搵晒全公司既所有 Project 一個個改, 這些處理手法在 AntiPattern 內亦有提及, 往往做成不良後果.

不過以上既推論都有重要既假設: 一個好既 OO Design 同 Design for Reuse. 如果設計得唔好, 就沒有人會用, 如果不是為重用而設計, 就不能重用.

對我在舊公司管理及維持左 Reusable Lib of Web Module, Data Module 同 Common Module 及不同 Internal Project 年幾時間既我, 加上接近七年前大專開始既軟件開發生涯, 在 OO Design 同 Design for Reuse 都自覺有相當既經驗, 雖然亦有好多不足既地方, 但亦希望跟住呢條路行. 而因未發新公司有現醒啱用既 Lib , 所以自己寫左一些重用到既 Lib, 加上 Project 開始繁忙而盡量希望在 Project 內實行軟件架構, 短期內應該有好多機會提升自己在設計及實行方面既經驗, 希望現實真係可以咁 Ideal 啦.

Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!