The art of programming




Programming principles
programming principles
High cohesion low coupling

Computer programming

编程作为我重要的谋生手段, 有必要审慎的加以考察审视. 程序设计应该包含那些最少的, 必备的, 重要的能力呢?
The practice of programming给出了大概的框架, 但不完整.
我认为最重要的就是Abstraction and design.
How to design programs还有SICP以及Elements of programming.
其次我们要掌握几门Programming language.
养成好的Coding style,
Valid and verification

Files sytle

kernel asm/asm-generic
asm stands for arch specific macros(FIXME).

Coding style

GNU Coding Standards
比如GNU coding standards, Linux kernel coding style, Shell coding standard
* Label
It is considered to be safer that the label reflect what happens at the
destination, and not the reason for reaching the label. –Julia

Verification and validation

抽象的知识来自生活经验的总结, 所以学习抽象知识的重要方向是从实践不断总结抽象.
programming is a goal-oriented activity
Before attempting to solve a problem, make absolutely sure you what the problem is.
Before developing a program, make precise and refine the pre/postcondition.
program ->
{Q} S {R}: predicte, formal notation
Q: input asseration
R: output asseration
predictes -> asseration
asseration: a predicate placed in a program is called an asseration.
Proof outline: a program together with an asseration between each pair of statements
Program specification ⊃ excution ∪ speed ∪ size
Instances: summation, squre root approximation, sorting
command-comment ⊃ all input ∪ output

Lock-free programming

ring buffer, rcu




Google testing blog
1.Black-box testing test software function.
2.White-box testing test software internal logic.

Good taste

// The “indirect” pointer points to the
// address of the thing we’ll update
indirect = &head;

// Walk the list, looking for the thing that
// points to the entry we want to remove

while ((*indirect) != entry)
indirect = &(*indirect)->next;

// .. and just remove it
*indirect = entry->next;

prev = NULL;
walk = head;

// Walk the list

while (walk != entry) {
prev = walk;
walk = walk->next;

// Remove the entry by updating the
// head or the previous entry

if (!prev)
head = entry->next;
prev->head = entry->next;