Powered By Blogger

2011年6月9日星期四

AWT vs Swing

Recently I am about to develope a java program with visual interface. From the very beginning, there are two definations needed to make them clear. That is , the differences between AWT and Swing.

When developing a Java program it is important to select the appropriate Java Graphical User Interface (GUI) components. There are two basic sets of components that you will most likely build your Java programs with. These two groups of components are called the Abstract Window Toolkit (AWT) and Swing. Both of these groups of components are part of the Java Foundation Classes (JFC).

An Overview of the AWT

AWT stands for Abstract Window ToolKit. The Abstract Window Toolkit supports GUI Java programming. It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window Toolkit provides the connection between your application and the native GUI. The AWT provides a high level of abstraction for your Java program since it hides you from the underlying details of the GUI your program will be running on.
AWT features include:

  • A rich set of user interface components.
  • A robust event-handling model.
  • Graphics and imaging tools, including shape, color, and font classes.
  • Layout managers, for flexible window layouts that don't depend on a particular window size or screen resolution.
  • Data transfer classes, for cut-and-paste through the native platform clipboard.
The AWT components depend on native code counterparts (called peers) to handle their functionality. Thus, these components are often called "heavyweight" components.

The Begin of Haskell

I have spent almost a week to learn how to use this language and finally I've developed the Baccarat in Haskell. Now I think it's really necessary for me to arrange my mind,which is messed up by this language.

First of all, this language is totally differnet with the previous language I've developed with, such as the OOP language: java, c++ and python or the imperative language:c. Actually it belongs to the functional language. In another way, functions in this language is " the first class", such as the variables or the parameters in OOP or imperative language. That is, you can take the function as the parameter or variable and do what the parameter or the variable can do.

Second, this language is called "purely". What purely means is that there is no side effect when you are programming, even if you are doing some  IO operations.

2011年6月2日星期四

zz.Cool Shell如何写出无法维护的代码

程序命名

  • 容易输入的名字。比如:Fred,asdf
  • 单字母的变量名。比如:a,b,c, x,y,z(陈皓注:如果不够用,可以考虑a1,a2,a3,a4,….)
  • 有创意地拼写错误。比如:SetPintleOpening, SetPintalClosing。这样可以让人很难搜索代码。
  • 抽象。比如:ProcessData, DoIt, GetData… 抽象到就跟什么都没说一样。
  • 缩写。比如:WTF,RTFSC …… (陈皓注:使用拼音缩写也同样给力,比如: BT,TMD,TJJTDS)
  • 随机大写字母。比如:gEtnuMbER..
  • 重用命名。在内嵌的语句块中使用相同的变量名有奇效。
  • 使用重音字母。比如:int ínt(注:第二个 ínt不是int)
  • 使用下划线。比如:_, __, ___。
  • 使用不同的语言。比如混用英语,德语,或是中文拼音。
  • 使用字符命名。比如:slash, asterix, comma…
  • 使用无关的单词。比如:god, superman, iloveu….
  • 混淆l和1。字母l和数字1有时候是看不出来的。

伪装欺诈

  • 把注释和代码交织在一起
1
2
3
4
5
6
7
8
9
10
11
for(j=0; j<array_len; j+ =8)<br />
{<br />
total += array[j+0 ];<br />
total += array[j+1 ];<br />
total += array[j+2 ]; /* Main body of<br />
total += array[j+3]; * loop is unrolled<br />
total += array[j+4]; * for greater speed.<br />
total += array[j+5]; */<br />
total += array[j+6 ];<br />
total += array[j+7 ];<br />
}
  • 隐藏宏定义。如:#define a=b a=0-b,当人们看到a=b时,谁也想不到那是一个宏。

2011年5月28日星期六

Wumpus world---Java Code

This is an artificial intellegence game design. In this game, there is a 4 by 4 square, and in this square, there exists one wumpus, some pits and one gold. The purpose of the game is let the computer controled robot to find the shortest path to find the gold and return to the start point. The game rule is simple, if the computer falls into a pit, it will be punished some pts and also it will be punished if it take any step, such as turn left, turn right, go forward or backward. Also it will be punished by arrowing the wumpus.And if it steps into the wumpu's square, it will lose lots of pts.
The only way to earn the pts is to take the gold.
This code use Djkistra's method to find the shortest path.
---Developed by Eclipse-SDK-3.5.2

Download address:www.dropbox.com

2011年5月27日星期五

zz.刘兴亮--中国互联网纳斯达克梦的醉与醒

阿Q喜欢说:“革命了,同去同去!”当下,互联网企业则流行:“上市了,同去同去!”一时间,万人空巷。有人开玩笑说,现在互联网行业只有两类企业,一类是已经上市,一类就是走在上市的路上。

奇虎360是今年第一家在美国资本市场上市的中国互联网公司,纽交所北京首代杨戈表示:“以奇虎360作为开始,预计2011年将有一批中国互联网公司赴美上市。”接下来,世纪互联、人人网、网秦小步快跑,也已经抢滩美国资本市场。

除了上述几家,等着要去美国上市的中国互联网公司,还有一个长长的队伍,主要集中在社交网络、网络视频、互联网软件服务、互联网信息服务、电子商务等领域。社交网站领域有开心网、淘米网、世纪佳缘等;网络视频领域有土豆网、PPLive、PPStream等;互联网软件服务领域有迅雷、UCweb等;电子商务领域有去哪儿、红孩子等;互联网信息服务领域有凤凰网、3G门户、易查等……


这幕情景是否很熟悉?是的,一而再,再而三,这已经是互联网行业的第三次上市潮了:


10年前的第一次互联网热潮,是由新浪、搜狐等三大门户网站来引领的。1999年7月,名不见经传的中华网在纳斯达克成功上市,融资8600万美元;2000年1月,在纳斯达克即将接近最高峰的时刻,再次发行新股,又募得令人惊讶的3亿美元,第一次让随后风险投资的加入与炒作,更是看到了中国市场的巨大商机,由此带动了三大门户上市热潮,以及一大批中国互联网公司的兴起。

zz.demo---写给和百度作战的文艺工作者们

我是一个靠写代码生活的人,我觉得我们这个行业,和创造文艺产品的人--比如写书的作家--是非常一致的,盗版问题同样影响着我们,只不过我们用的是和作家不一样的语言来创造产品。比作家们幸运的是,我们可以完全脱离中国市场,去做英文的德文的日文的法文的软件,而且特别不要做中文的软件,这样才能让自己的作品在一个正常市场内销售并获得应有的收益。我们认为中国的问题无解,于是我们放弃了。我们不再愿意创造中国人普遍可用的工具,因为赚不到钱。作家们比我们悲哀一些,因为文化和语言是有民族性的,你们不能把中文的作品卖给其他国家的人,也很难快速学会用其他文字写作。于是,你们只能死磕。

在前面的这些年,大家始终没意识到这个问题的严重性,也从来没有什么行动,虽然你们可能早就从百度mp3下载音乐,下载盗版软件,损害着其他领域的创造者们。今天你们也面临着一样困境。现在痛苦终于降临到了你们身上。

或许你们还记得,不到一年之前,google books索引你们的书,仅仅是索引(用户只能在搜索的时候展现片段内容做为提示),而不是让用户阅读,google就愿意付给你们60美元。但你们嘲讽的拒绝了,你们认为那是作恶。比如王晓峰这篇 《股沟挖了一条沟》 当时我就明白,过不了多久,你们会后悔的,但是确实没想到来的这么快。事实上google books确实没有作恶,他们做的事情和书商摘取你们作品的片段放在广告宣传页上一样,让读者搜索感兴趣的内容的时候,知道你的书中有提及,如果要阅读,需要付费。

数字化大潮势不可挡,这本来是全球搜索巨人释放的极大的善意,这大概也是数字阅读解决方案中,技术和商业结合最好的方式。可惜王晓峰这种自傲的文人认为是作恶。他那篇讽刺google的文字到现在还能搜索到很多,我承认王晓峰影响力不小,但他错了。大部分作家或许都是这样,他们活在自己理解的世界中,不愿意学习新东西,甚至连多想一些都不愿意。在他们的世界里,就是出版卖书赚钱,从来没想到世界变化如此之快。在上一次对google的攻击中,只有韩寒认真的了解了google到底干了什么,并公开发文支持。对这个事情有兴趣的可以读韩寒这篇blog:http://blog.sina.com.cn/s/blog_4701280b0100fzmm.html

ATTENTION

Hi,
     If anyone wanna get the code, please log in the dropbox and get it. Cuz the Blogger doesn't have the function of uploading files.
     The website of dropbox is : http://www.dropbox.com/
      User name:jintianqi@gmail.com
    Password:1234567890