ProfileLEO, A ProgrammerPhotosBlogLists Tools Help

Blog


    August 23

    时间

        今天一个朋友的名字挺有意思,“时间是静止的,我们才是流逝的”, 不论这是颇有哲理的一句话,还是某位抑或哪位高人的闲时感悟,这句话却勾起我的一些情绪。
        想想看,自己17岁从老家流到北京,从幼时的天真到三十而立,时间寂静而没有一丝改变,我却变了了。时间不会逝去,但有一天我们终将逝去。
        自己一直在刻意在淡化时间在自己的空间落下的痕迹,而有些细节却时时提醒着时间的存在, 奶奶身体不好了,外婆也终于风湿腿寒到了限度卧病在床,我的记忆里她们带着那个满眼清澈的小男孩玩耍的时间总是就在昨天?
        故事是昨天的,希望是明天的。我们继续流逝。
    August 02

    Script IDE

    Why there is no good IDE for JavaScript? Any one know some and could recommand something?
    these days mess in my brain, not productive.
    July 15

    It's not funny

    Be honesty, I feel the guys who draws these pictures either not know China or have some special purpose.
    There are lots of scarcities with China, it is real, but you can not imagine that this nation have achieve greate improvement since 1980. if you have been Beijing when the night it win the 2008, you will know the feeling of a common Chinese people.
    These guys not, I guess they think they "outbalance" us, and this pictures could let them been focused and famous, but at least I will not keep on watching these.
    July 10

    Peace

    I'm Shocked by the terrorism in London, and wish that will not happen again.
    July 03

    <<Java Rules>>

    Although it was published 2-3 years ago, but I think this book still worth you to read it.
    The basic concept and somethign deep in side codes, but it is a pity I just have the Chinese version, not excellent.
    If you concern performance of your codes and something behind the java sdk, you'd better to read it.
    July 01

    JavaScript inherit issues

    1.Array or Object member inherit issue,

     An Array or Object member in prototype will be shared by the instances of the class, since it is not deep copied to the instance, just reference, thus change one instance member will affect others.
     function copyObject(srcObj,desObj){
     var memberType="";
     for(var member in srcObj){
      if(typeof srcObj[member]=="object"){
       desObj[member]=(srcObj[member].constructor==Array)?[]:{};
       copyObject(srcObj[member],desObj[member]);
      }else{
       desObj[member]=srcObj[member];
      }
     }
    }
    //class Test
    function Test(){
    }
    //set a array type for Test's prototype
    Test.prototype.tArr=[];
    //Class Test2
    function Test2(){
    }
    //not use system.define method, but copy all Test.prototype to Test2's in deep
    copyObject(Test.prototype,Test2.prototype);

    function testT(){
     var t1=new Test();
     //change t1's tArr[0]
     t1.tArr[0]="orginal";
     //will not affect Test2's new instance it should alert undefined
     var t2=new Test2();
     alert(t2.tArr[0]);
     
     //problem comes, t3 is also a new Test without set tArr but now the tArr[0] have value
     //that setted by t1.
     var t3=new Test();
     alert(t3.tArr[0]);
    }
    2. IE6 and Firefox's diffrent in handling prototype:
    codes here first:
    function Test1(){
    }
    Test1.prototype.t="hello";
    Test1.prototype.f=function(){
     alert("hello! world");
    }
    function copyObject(srcObj,desObj){
     var memberType="";
     for(var member in srcObj){
      if(typeof srcObj[member]=="object"){
       desObj[member]=(srcObj[member].constructor==Array)?[]:{};
       copyObject(srcObj[member],desObj[member]);
      }else{
       desObj[member]=srcObj[member];
      }
     }
    }
    function Test2(){
    }
    copyObject(Test1.prototype,Test2.prototype);
    for(var mem in Test2){
     alert(mem);
    }
    If you tried to loop Test2 Class  before copy a prototype to it, IE and Firefox will not alert a "prototype" both. at this point, they are same, but after Test2 get a prototype, like codes above, Firefox will alert a member name "prototype" but IE will not. So if you want to copy prototype from one class to another in IE, you should do like this "copyObject(Test1.prototype,Test2.prototype);
    " but not "copyObject(Test1,Test2);", as you can imagine, firefox will allow you to do it with second aproach.