Clean Coding Principles in C# 課程連結
Why Writing Clean Code Matters
前言
Programmer is the are of telling another human what one wants computer to do --- By Donald Knuth
Any fool can write code that a computer can understand. Good programmer writes code that human can understand
我們都可以輕易寫出執行邏輯符合期望表現的程式, 但這只是基本, 如果我們要自稱為程式設計師 , 那麼我們應該試圖寫出他人可以輕易看得懂的程式碼.
Ci Ty Chen changed 2 years agoView mode Like 1 Bookmark
抽象化
抽象化(英語:Abstraction)是指以縮減一個概念或是一個現象的資訊含量來將其廣義化(Generalization)的過程,主要是為了只保存和一特定目的有關的資訊。例如,將一個皮製的足球抽象化成一個球,只保留一般球的屬性和行為等資訊。相似地,亦可以將快樂抽象化成一種情緒,以減少其在情緒中所含的資訊量。
Abstraction describe what
e.g.
Send a Message
Store a Customer record
Details specify how
Ci Ty Chen changed 2 years agoView mode Like 4 Bookmark
What We Should Defend From ?
Define Defensive Coding
Defensive coding is an approach to improve software and source code, in terms of:
General quality - reducing the number of software bugs and problems
Making the source code comprehensible - the source code should be readable and understandable, so it is approved in a code audit.
Making the software behave in a predicatable manner despite unexpected inputs or user actions.
Ci Ty Chen changed 2 years agoView mode Like Bookmark
軟體設計
定義
The final goal of any engineering activity is the some type of documentation. When a design effort is complete, the design documentation is turned over to the manufacturing team. This is a completely different group with completely different skills from the design team. If the design documents truly represent a complete design, the manufacturing team can proceed to build the product. In fact, they can proceed to build lots of the product, all without any further intervention of the designers. After reviewing the software development life cycle as I understood it, I concluded that the only software documentation that actually seems to satisfy the criteria of an engineering design is the source code listings.
約三十年前以工廠為導向的思考方式會認為軟體設計的產出物是 UML 圖
老闆覺得只要將 UML 圖給工程師 , 就可以讓工程師照圖施工 , 複製出產品.
現在的思維則是認為軟體設計的產出是程式碼 (Source Code)
Ci Ty Chen changed 3 years agoView mode Like 2 Bookmark
Count、Sum、Average、Min、Max 是 LinQ 內用來進行統計運算(?)的函數. 其與 First 相同 , 都是立即執行(Immediately execution)查詢. 因此不用擔心延遲執行的問題. 另外需要特別注意的是上述函數的回傳值只可能是 Value Type 以及 Nullable Type . 也就是說 , 像是回傳學生集合中成績最小的學生物件 , 這個動作是無法達成的.
Min
回傳序列中指定項目的最小值.
常用的多載形式如下(不只)
TSource Min(this IEnumerable)
Returns the minimum value in a generic sequence.
Ci Ty Chen changed 3 years agoView mode Like Bookmark