David's profileprowyh's spaceBlogLists Tools Help

Blog


    March 28

    Waiting for CLR via C#......

    前段时间听朋友介绍,说《CLR via C#》是amazon.com上被评为五星级的书,今天突然想起来,就去看了看,果然……
     
    《CLR via C#》的作者是大名鼎鼎的Jeffrey Richter,难怪评价如此之高!
     
    About Jeffrey Richter:
     
    Jeffrey Richter is a co-founder of Wintellect, a training, debugging, and consulting firm dedicated to helping companies build better software, faster.   Over the years, Jeff has consulted for many companies including Intel, DreamWorks and Microsoft. In fact, for Microsoft, he has contributed both design and code to the following products: Windows (all 32-bit and 64-bit versions), Visual Studio .NET, Microsoft Office, TerraServer, the .NET Framework, "Longhorn" and "Indigo". Even today, Jeff is still consulting with Microsoft's .NET Framework team (since October 1999) and XML Web Services and Messaging Team ("Indigo") (since January 2003).

     
    He is the author of several best selling .NET and Win32 programming books including:   The Applied Microsoft .NET Framework Programming in C# Collection Applied Microsoft .NET Framework Programming Applied Microsoft .NET Framework Programming in Microsoft Visual Basic .NET Programming Applications for Microsoft Windows (formerly Advanced Windows). Programming Server-Side Applications for Microsoft Windows In addition, Jeff has also contributed to many other books including: Programming Microsoft Visual Basic .NET (Core Reference), .NET Framework Standard Library Annotated Reference, Vol. 1: System, System.Collections, System.IO, System.Diagnostics, System.Globalization, System.Security, System.Text, System.Threading Microsoft .NET Framework 1.1 Class Library Reference Volumes 1-4: System. Jeffrey is also a contributing editor to MSDN Magazine where he authors the .NET column and has written many feature articles.
     
    一点花絮:
     
    《CLR via C#》的第一版名为《Applied Microsoft .NET Framework Programming》,其修订版之中文版由李建忠译,本来由李建忠接着翻译第二版即《CLR via C#》是顺理成章之事,可人算不如天算,李建忠在这里道出了其中原由
     
    现在很多人掰着字典、点着金山词霸在译书!以前在电视上看过陆谷孙先生的讲演,说以前中国人对文字是很敬畏的,曾有“敬惜字纸”的条幅……人心不古,其奈也何?
     
    为了表示对《CLR via C#》作者Jeffrey Richter的尊重,期待着该书的影印版……实在不行,就请有到国外出差的朋友给捎一本罢^_^
    March 23

    A romantic scene

    A scene from an object-oriented romance:
     
    Object A: Darling, don't ever change!
    Object B: Don't worry, dear, I'm const.
     
    A wonders, "Can B be trusted?" The answer often hinges on B's nature: the constitution of its member functions.
     
     
    -- excerpted from Effective C++ by Scott Meyers

    关于WebServices的一点注记

    《Core C# and .NET》以及.NET的资料关于DataList.asmx文件的WebService指令的说明:Class="LevenSite.DataList, DataList"意味WebService的代码封装在DataList.dll文件中,这样DataList.asmx文件就只有这一行指令,这样即可有效保护代码的知识产权。
     
    DataList.asmx.cs文件源代码:
     
    using System;
    using System.Web;
    using System.Web.Services;
    namespace LevenSite
    {
        [WebService(Namespace = "http://www.levensoft.com/WebService")]
        public class DataList : System.Web.Services.WebService
        {
            public DataList()
            {
                InitializeComponent();
            }
        }
        [WebMethod(Description="GetDataList")]
        public string GetDataList()
        {
            return "Hello World!";
        }
    }
     
    这段代码如果放在DataList.asmx中,一切正常,如果调用此WebService,则得到"Hello World!"的结果,但如果将此段代码另存为DataList.asmx.cs并且编译为DataList.dll,从而在DataList.asmx文件中按开头给出的WebService指令调用的话,则出错,原因是DataList.dll文件格式无效。
     
    经过多次努力后,发现问题出在.NET的版本上,这种代码分离方式只有.NET 2.0支持,.NET 1.x是不支持的!这一点,《Core C# and .NET》以及.NET的文档都没有提及!
    March 13

    Spring

    by William Blake
     
    Sound the Flute! Now it's mute.
    Birds delight Day and Night;
    Nightingale In the dale,
    Lark in Sky,
    Merrily, Merrily, Merrily, to welcome in the Year.
     
    Little Boy, Full of joy;
    Little Girl, Sweet and small;
    Cock does crow, So do you;
    Merry voice, Infant noise,
    Merrily, Merrily, to welcome in the Year.
     
    Little Lamb, Here I am;
    Come and lick My white neck;
    Let me pull Your soft Wool;
    Let me kiss Your soft face:
    Merrily, Merrily, we welcome in the Year.

     
    春天
    威廉•布莱克
     
    长笛的声音,现已不响
    鸟儿们日夜欢唱
    山谷中的夜莺
    天空中的云雀
    欢乐啊,欢乐啊,欢乐啊,欢迎你来此徜佯
     
    小男孩儿,充满快乐
    小女孩儿,满脸欢笑
    公鸡喔喔叫
    童声稚语来环绕
    欢乐啊,欢乐啊,欢迎你的来到
     
    小羊羔,我在这儿
    快来舔舔我的白脖儿
    让我摸摸你软软的毛
    让我亲亲你嫩嫩的脸
    欢乐啊,欢乐啊,欢迎你——春天
     
    注:女儿要求给她找一首描写春天的英文诗,出板报用。Google一下,发现这首William Blake的《Spring》写的很好,就花了一晚上,硬翻译了出来,结果被评为“像儿歌,没诗味”,也难怪,诗本来就是不能翻译的!:-)
     
     
    William Blake (1757-1827), English artist, mystic and poet wrote Songs of Innocence (1789): a poetry collection written from the child’s point of view, of innocent wonderment and spontaneity in natural settings.

    什么是JSON?

    前文说到mashups的技术基础时,提到JSON是其中之一,那么什么是JSON?
     
    1、定义
     
    JSON = JavaScript Object Notation,顾名思义,是一种用JavaScript表示(描述)对象的一种方法(记法),D. Crockford在RFC4627中的定义为:
     
    JavaScript Object Notation (JSON) is a lightweight, text-based, language-independent data interchange format.  It was derived from the ECMAScript Programming Language Standard.  JSON defines a small set of formatting rules for the portable representation of structured data.
     
    1)JSON是一种轻量级的,基于文本的,语言无关的数据交换格式。简单扼要的一句话,就说明了什么是JSON。
     
    轻量级——与SGML、XML相比较而言,借用JSON作者的话说,是一种Fat-Free Alternative to XML(去掉了XML的脂肪,留下了XML的骨感风韵)。
     
    基于文本——采用XML的成功作法,而且由于要做“语言无关的数据交换格式”,基于文本是必须的。
     
    语言无关——虽然是从ECMAScript衍生而来,但由于只采用了ECMAScript中的数据表示法,可以很容易地在其它语言中实现,并非特别绑定于ECMAScript。
     
    数据交换——由于JSON衍生自程序语言,天生用于描述结构化的数据。而XML由于出自“文档世家”SGML,所以天性适合于描述文档。当然,XML的描述能力比JSON要强,可以描述半结构化数据,而JSON只适合于描述结构化的数据。
     
    2)是从ECMAScript程序设计语言衍生而来的。
     
    JSON采用了ECMAScript语言的数据(对象、数组以及其它标量数据)表示法。
     
    3)JSON定义了几条简单的格式化规则用于表示可移植的结构化数据。
     
    格式化规则体现于下面的语法定义。
     
    2、语法
     
    D. Crockford在www.json.org中给出了JSON的语法定义:
    object
    {}
    { members }
    members
    pair
    pair , members
    pair
    string : value
    array
    []
    [ elements ]
    elements
    value
    value , elements
    value
    string
    number
    object
    array
    true
    false
    null

    由此可以看出,JSON的语法特简单!

    3. 例子

    下面是一个D. Crockford给出的例子

    {
        "glossary": {
            "title": "example glossary",
            "GlossDiv": {
                "title": "S",
                "GlossList": {
                    "GlossEntry": {
                        "ID": "SGML",
                        "SortAs": "SGML",
                        "GlossTerm": "Standard Generalized Markup Language",
                        "Acronym": "SGML",
                        "Abbrev": "ISO 8879:1986",
                        "GlossDef": {
                            "para": "A meta-markup language, used to create markup languages such as DocBook.",
                            "GlossSeeAlso": ["GML", "XML"]
                        },
                        "GlossSee": "markup"
                    }
                }
            }
        }
    }


    其等价的XML表示为:


     
     
      
      
       
        SGML
        SGML
        Standard Generalized Markup Language
        SGML
        ISO 8879:1986
        
         A meta-markup language, used to create markup languages such as DocBook.
         SGML
         XML
        
        markup
       
      
     

    注:这个XML表示是我从JSON表示中推出的,与D. Crockford给出的XML表示有所不同。

    March 11

    WOA - Web-Oriented Architecture

    Dion Hinchcliffe在《The SOA with reach: Web-Oriented Architecture》中对WOA(SOA的轻量级版本:WOA is a lightweight version of SOA)做了一番描述:
     
    1、Essentially, WOA describes a core set of Web protocols like HTTP and plain XML as the most dynamic, scalable, and interoperable Web service approach.  The only real difference between traditional SOA and the concept of WOA is that WOA advocates REST, an increasingly popular, powerful, and simple method of leveraging HTTP as a Web service in its own right (and carefully devised by the co-creator of HTTP, Roy Fielding.)
     
    2、An important concept in Web 2.0 is that Web-based software should offers its functionality not only via the browser, but also as open Web services so that it can be mashed up in new and unintended ways.  This takes software from being a mere application and turns it into a true platform.  A great many new online software applications are actually doing this now, even if it’s just one-way via RSS. 
     
    3、The theory of sharing your application’s pieces as Web services is that it allows your functionality and data to be useful to others in innovative ways you won’t be able to predict ahead of time. People can take your best features and combine them with others, allowing you to become part of a larger supply chain instead of being limited to your individual delivery channel.  It’s an interesting value proposition that the growing mashosphere seems to be validating.  And we shouldn’t forget that SOA encourages this exact same view by liberating the silos of data and software in an organization as Web services, making it possible to share and reuse them anywhere inside an organization in a loosely-coupled and interoperable way.
     
    一般说来,SOA是建立在SOAP基础上的,由于SOAP的复杂性(Ironically,SOAP中的S是指Simple,但现在SOAP却变得越来越复杂,或者说,由于要求SOAP/Web Services要具有稳定性、安全性而不得不加上一层又一层的wrap),使得SOA越来越复杂,越来越重(heavyweight)。
     
    WOA建立在REST的基础上,没有对HTTP做任何扩展,特别适合于松散偶合(loosely-coupled)的mashups。
     
    REST是Representational State Transfer的缩写,是Roy Fielding在其博士论文中提出的概念,用于描述分布式多媒体系统的结构风格(Architecture Style),但并非一种标准规范。关于REST后文再述。
     
    mashups是最近流行的一个新词,是指Web小程序(Badgets, Widgets, Gadgets, etc)的拼装组合,mashups的技术基础是REST、JSON、Ajax。关于mashups,后文再说。
    March 09

    三言两语,再说于丹

    这一亩二分地,已尘封日久,今日偶得偷闲,故起一大早,好做“晨兴理荒秽”……
     
    最近关于于丹的热点莫过于所谓“10博士联名,称要‘将反对于丹之流进行到底’”了。 仔细读过徐博士的大作,感觉文体有点久违了的大字报的味道,请看:
    1、一个凭借强势媒体的巨大影响力,以阉割中国传统优秀文化为乐事的高学历文盲
    2、某些编辑记者缺乏起码的文化良知和基本的人文素养
    3、安意如用说诗词的方式去意淫中国古代那些高雅的生命
    4、于丹用《心灵鸡汤》般的语言来猥亵孔子
    5、像于丹这样一个古汉语知识连初中文化水平都达不到的“影视学博士”,仅仅靠耍嘴皮子就可以获得社会荣誉
    6、那些把人文理论庸俗化和媚俗化的人们,要么是因为别有用心,要么是因为极度无知。于丹是后者
    7、于丹之流会很富有,但没有社会地位
    8、意淫、猥亵,巧言令色,谄视媚行
     
    有人说,不规范地使用汉语,确使人有“出轨”的快感!那么,徐博士这些“国骂”应该使其“高潮不断”了!……
    我们古人讲“知书达礼”,以吾等草民近乎文盲之心揣之,意为“读书越多,越明白事理,越懂得礼节,也越能产生对人、事、物的尊敬之心”!以徐博士之“博士”头衔(好像还是“博士生”)来看,应该是“书”读得不少了,却没见其知书而后达礼也……现在这博士,也太水了!
     
    在仔细读过几遍之后,终于读出了“文眼”:“那些付出了巨大的努力,学问充盈的人士会变得很穷,而那些最浅薄的作者,却可以通过廉价推销作品获得大大的财富”!
    呵呵,是啊,有人“皓首穷经”一辈子,也没能实现知识到资本的转化。而于丹,却转化地太快!从而,有人“捶胸顿足”,有人“泼妇骂街”,有人……,哎,这种古老的人类心理……我不知道有没有哲学家预言过,在极遥远的未来,这种心理会消失吗?
     
    以上所举8条立论,都是为其中心“文眼”服务的,所以不值得一一反驳了!唉,这“博士”也太可怜了……