WanCW’s Study Notes

 

Wise programming techniques for writing quality code

  1. Think before coding
  2. Fix bugs immediately
  3. Test individual functional elements
  4. Test complete puzzle
  5. Write robust code components
  6. Fail as early as possible
  7. Avoid quick hacks
  8. Use defensive programming
  9. Prefer strong typing over dynamic binding
  10. Write self-explanatory code
  11. Avoid sophisticated code
  12. Avoid dense code blocks
  13. Avoid code duplication
  14. Avoid magic constants
  15. Strive for loose coupling
  16. Avoid hidden dependencies
  17. Strive for flat responsibility distribution
  18. Keep related code close together
  19. Build a house, not an empire
  20. Redesign when needed
  21. Do not sacrifice quality

Filed under  //   Software Develop  

Comments [0]

IE conditional comment gotcha

<!-- [if IE]> (bad)
<!--[if IE]> (good) 

Filed under  //   HTML   IE   Web Develop  

Comments [0]

10件敏捷專案時間管理原則

  1. 利用DoD (Defintion of Done)
  2. 使用時間框(timeboxes)去管理工作
  3. 不要在自己的工作評估時保留buffer
  4. 延遲再決定
  5. 縮短生產週期
  6. 保持pipeline短而細
  7. 維持紀律
  8. 限制工作互換
  9. 預防持續的加班
  10. 分離急迫性和重要性

Filed under  //   Agile   Software Develop   Time Management  

Comments [0]

用iTunes製作鈴聲

Filed under  //   iPhone  

Comments [1]

Prevent a Dotted Border around a Hyperlink when clicked in FireFox

a:focus {
    outline: none;
}

Comments [0]

How to think about OO

  • Static methods ⇒ 不是 OO!
  • 沒有用到成員資料的 instance methods ⇒ 不是 OO!
    (無異於 static methods。)
  • method 應該屬於與之互動最多的 object。
  • 多數的條件分支(if、switch)都可以用多型方式取代。
  • 不需要一併作 serialization/persistence 的資料以參數方式使用即可,
    不要作為成員變數。
  • 不要為不確定的「如果……」付出太多心力。

Filed under  //   OOP  

Comments [0]

The 5 Static Code Audits every developer should know and use

  1. Numerical Literal in Code ⇒ give a meaningful name.
  2. String Literal ⇒ retrieve string from resource bundle.
  3. god Method/Class/Package:

    3 audits: Long Methods, Long Parameters, and Switch statements.
    4 metrics: Line of Code (LOC), Number of Parameters (NOP), Number of Local Variables (NOLV), and Maximum Number of Branches (MNOB).

  4. Shotgun Surgery:

    2 metrics: Changing Methods (CM) and Changing Classes (ChC).

  5. Duplicate code

 

Filed under  //   Code Review  

Comments [1]

12 Things to Shorten Your Lead Time in Software Development

  1. Measure, measure, measure
  2. Increase quality
  3. Reduce rework
  4. Frequent releases
  5. Stop working in parallel
  6. Shorter stories
  7. Visualize and manage flow
  8. Rigorously cancel meetings
  9. Continuous deployment
  10. Shorten product management
  11. No single point of failure or bottleneck
  12. Leveling work

 

Filed under  //   Software Develop  

Comments [0]

Best way to load your JavaScript

function loadScript(url, callback){
 
    var script = document.createElement("script")
    script.type = "text/javascript";
 
    if (script.readyState){  //IE
        script.onreadystatechange = function(){
            if (script.readyState == "loaded" ||
                    script.readyState == "complete"){
                script.onreadystatechange = null;
                callback();
            }
        };
    } else {  //Others
        script.onload = function(){
            callback();
        };
    }
 
    script.src = url;
    document.getElementsByTagName("head")[0].appendChild(script);
}

 

Filed under  //   JavaScript   Web Develop  

Comments [0]

Text Rotation with CSS

-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);

Filed under  //   CSS  

Comments [0]