DesignOfEverydayThings - What I learned as a developer


I only notes part of "Fundamental Principles of Interaction"
It's just a small unit of this book, but already help me A LOT.
Whenever I'm confused of designing, I re-read this book to get more ideas.

Because I'm a developer, so the most important thing it taught me is:
Why we need write clean code, how a clean code look like? How to know a design is good or bad.

  • Affordance and Signifier: That's why we need good naming.
    • Ex. visible signifier
StringUtils.trimToEmpty
StringUtils.substringBetween
    • Ex. Invisible
String dateString = PrivateDateUtils.toDateString( date ); // What is the format?

@SuperAnnotation // Things become invisible when there are many decision made at runtime, developer won't know.
public class NormalClass {}
  • Mapping and Conceptual Models: Developers always handling mapping and conceptual models
PersonDao.persist( person ); // Clear model, dev expect it will persist
Person.save(); // May be a little confuse
personService.find( id ); // When a find method persist data due to other reason such as queue full or statistics, it become confusing
  • Feedback: We need many feedback, no matter in code or in performance tunning or monitoring
personService.find( id ); // It's better to response quickly
personService.find( id, timeout, TimeUnit ); // It's better to provide timeout when things may become long

public void find(String id) {
    try {
        personDao.someErrorMayHappen(); 
    } catch (Exception ex) {
        // Eveything is find, treat as no data
    }
}
    • When there are too many error, we even unable to know the feedback is valid or not


沒有留言:

張貼留言

別名演算法 Alias Method

 題目 每個伺服器支援不同的 TPM (transaction per minute) 當 request 來的時候, 系統需要馬上根據 TPM 的能力隨機找到一個適合的 server. 雖然稱為 "隨機", 但還是需要有 TPM 作為權重. 解法 別名演算法...