|
從 Rob Pike 的 Google+ 上的一個(gè)推看到了一篇叫《Understanding Object Oriented Programming》的文章,我先把這篇文章簡(jiǎn)述一下,然后再說(shuō)說(shuō)老牌黑客 Rob Pike 的評(píng)論。
先看這篇教程是怎么來(lái)講述 OOP 的。它先給了下面這個(gè)問(wèn)題,這個(gè)問(wèn)題需要輸出一段關(guān)于操作系統(tǒng)的文字:假設(shè) Unix 很不錯(cuò),Windows 很差。
這個(gè)把下面這段代碼描述成是Hacker Solution。(這幫人覺(jué)得下面這叫黑客?我估計(jì)這幫人真是沒(méi)看過(guò)C語(yǔ)言的代碼)
public class PrintOS{ public static void main (final String[] args) { String osName = System.getProperty ("os.name") ; if (osName.equals ("SunOS") || osName.equals ("Linux")) { System.out.println ("This is a UNIX box and therefore good.") ; } else if (osName.equals ("Windows NT") || osName.equals ("Windows 95")) { System.out.println ("This is a Windows box and therefore bad.") ; } else { System.out.println ("This is not a box.") ; } }}
it知識(shí)庫(kù):如此理解面向?qū)ο缶幊?/a>,轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。