How to debug C/C++ pointers

for (int i = 0; !prog.isCompiled(); i = (i + 1) % 7) {
    switch (i) {
        case 6: look up videos to explain pointers;
        case 5: go look at that code that worked right once;
        case 4: look up pointers online;
                delete *'s and &'s;
        case 0: 
        case 3: add *;
                break;
        case 1: add &;
                break;
        case 2: swap & and *;
                break;
        default: find the geek of the office;
}
Advertisements
Posted in Uncategorized | Leave a comment

Programming Principles

Source:

https://www.makeuseof.com/tag/basic-programming-principles/

https://www.makeuseof.com/tag/weird-programming-principles/

 

Basic:

  1. Keep It Simple, Stupid
  2. Don’t Repeat Yourself   (better than Write Everything Twice and Waste Everyone’s Time)
  3. Open to extension but Closed to modification
  4. Composition over Inheritance
  5. Single Responsibility
  6. Separation of Concerns
  7. You Aren’t Gonna Need It
  8. No Premature Optimization
  9. Refactor, Refactor, Refactor (since code rarely comes out right the first time)
  10. Clean code > Clever code

 

Extensions:

  • The Bloat Principle

Zawinski’s Law: “Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.”

“Software expands to consume all available resources.”

(That’s why I hate Wechat.)

  • Worse is Better mentality

“Software that is limited, but simple to use, may be more appealing to the user and market than the reverse.”

Software Peter Principle: “A overly complex project will eventually become too complex to be understood even by its own developers.”

(That’s why I hate Wechat.)

  • Principle of Least Astonishment

“If a necessary feature has a high astonishment factor, it may be necessary to redesign the feature.”

(That’s why I hate Wechat.)

  • Eagleson’s Law

“Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.”

(That’s why I … fine.)

  • Lubarsky’s Law of Cybernetic Entomology

“There’s always one more bug.”

(Ain’t that the truth!)

  • Kernighan’s Law

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” (ROFL)

“Indeed, the ratio of time spent reading versus writing is well over 10 to 1. We are constantly reading old code as part of the effort to write new code . . . [Therefore,] making it easy to read makes it easier to write.”

 

One more bug duck:

Rubber Duck Debugging

Debug broken software by explaining your code to an inanimate object (e.g. a rubber duck) one line at a time.

(Please click the donate button so I can afford a rubber duck, please~~~)

+--------+
| Donate |
+--------+

 

Posted in 计算机与 Internet | Leave a comment

隨筆其二

一翦梅

殘雨更闌寒寺鐘,煙鎖平湖,月染江楓。青燈獨向惱春風,來也幽幽,去卻匆匆。

傾玉壺、銀灑落紅,醒似懨懨,醉似朦朦。香魂欲斷托孤鴻,擡筆綿綿,落筆空空

Posted in Uncategorized | 2 Comments

隨筆其一

相見歡

瀟瀟一夕風流,證因由。冥冥尋尋覓覓念悠悠。

驀回首,香遊袖,月迷舟。卻是誤將仲夏當深秋。

 

注:粵語韻調。

Posted in Uncategorized | 2 Comments

蝶・戀・花

詞牌: 蝶戀花

碧翠嫣紅何度寵? 裊裊情華,難繾芳心動。 一紀斷腸牽古墓,絕情半世藏思慟。

幽影重重寒露重, 嚦嚦黃鶯,驚醒莊周夢。 梁祝台前魂魄舞, 奈何天上絲竹弄。

IMG_20170517_223111.jpg
IMG_20170522_214827.jpg
IMG_20170522_214913.jpg
_DSC0076.jpg

花惜痴情海,蝶怨離恨天。

藉此封紙停筆。

Posted in Uncategorized | Leave a comment

May the flower be with you

流水相去落花還,月浸前溪獨憑欄。

簾外盡聽春風笑,鏡中不展胭脂顏。

 

注:因為是用粵語寫的,寫完才發現用普通話讀起來有些拗口……

不管了,當是古音吧(不負責任狀

Posted in Uncategorized | Leave a comment

七夕・改

標題看上去十分中二詭異……

一日兩更根本是破紀錄了。

稍微改了一下之前的七夕詩,遲些時候可用於贈予兩位友人。

(原詩贈人的話也許會被以為是詛咒……)

澄波渺渺盼星辰,

碧落茫茫染紅塵。

莫傷銀漢難為渡,

鵲橋自濟有緣人。

(希望不會出現 真・七夕・超魔改 這種標題……)

Posted in Uncategorized | Leave a comment