如此理解面向对象编程

  从 Rob Pike 的 Google+ 上的一个推看到了一篇叫《Understanding Object Oriented Programming》的文章,我先把这篇文章简述一下,然后再说说老牌黑客 Rob Pike 的评论。

  先看这篇教程是怎么来讲述 OOP 的。它先给了下面这个问题,这个问题需要输出一段关于操作系统的文字:假设 Unix 很不错,Windows 很差。

  这个把下面这段代码描述成是Hacker Solution。(这帮人觉得下面这叫黑客?我估计这帮人真是没看过C语言的代码)

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知识库如此理解面向对象编程,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。