網站作為一個信息供給系統

就目前為止,我對網站作為一個信息供給系統的看法。
當然,網站不止於信息供給功能,人們還可以發布信息和交流信息。

信息供給系統是指一個能向用戶提供有用信息的系統。
它是相對的。一個系統能提供的信息對一些用戶有價值,對於其他用戶可能沒有價值。
信息供給系統必需滿足兩個條件:
1.有價值的信息在系統中存在;

2.用戶可以通過某種實際可行的途徑得到這部分信息。

信息供給系統的評價標準
對於一個用戶,系統屬於信息供給系統的條件下,評價它的標準:
1.取得信息的難度(技術難度,視線難度。。)
2.取得信息的用時
3.信息價值的大小,用戶最後得到信息後對信息的滿意度。信息的相關性,信息的準確度,信息的時效,信息的完整程度。。。

信息供給的途徑
1.搜索
優點:直接,快速
缺點:要先得到關鍵詞,很難控制相關性。

2.索引
優點:系統化,用戶可以不知道關鍵詞,通過大概的感覺找到信息;可以瀏覽,讓用戶得到一片信息,而不是一點
缺點:比較費時(但如果能順利找到,用戶應該不介意)
網頁的分類,TAG,導航系統也可以看完一個索引系統。
要使用清晰準確易懂的關鍵詞作為分類名。不要給用戶任何“驚喜“
索引分類結構要合理,要讓用戶一眼能看出來他要的子分類藏哪一主分類之下。
一個終端類目下的條目不應該過多,過多的條目不方便挑選。
索引最好有合理排序功能,通過列表的條件關係,加速信息查找。

信息供給系統的最高目標:
立現你所需,不多,也不少。
立:速度快
現:不費力,主動“現”
你:個性化,針對性
所需:相關性
不多:無干擾信息,無不相關信息
不少:信息量完整。

發表在 信息處理, 站長文檔 | 標籤為 | 留下評論

女朋友

在嘉陵江邊的亂石灘上,伴着潺潺的江水,吹着讓人舒心的風,坐着的卻是一對沉默着的情侶--男孩低着頭,偶爾也會嘗試帶着笑臉看一眼女孩,但女孩瞪一眼男孩,把綳得緊緊的臉轉開一點,繼續不搭理他。。。於是男孩只得掃興地再次慢慢低下頭。。。

他們就坐着,坐着。。。寧靜得像這就是他們的世界盡頭。。。

突然一石子被投向了江里,“咚“的一聲,江面上散開了幾圈波紋。二人同時轉身,看到一個正在散步的人從腳下又拾起一石子,向江面投了出去。。。

女孩看了一會,站起來俯身探了幾步,也拾起一塊石子,然後隨手將它向江面擲了出去,但飛出的石子馬上墜落,落在僅幾步之遙的江面上。。。

這時男孩帶着一塊石子向移江邊和女孩並站到了一起,舉起手中的石子--他沒有把石子拋出,而是虔誠地把它送到女孩的前面。。

女孩看了他一眼,又看了一眼他手中的石子,停了一會,還是伸手接過了石子,把它向江面擲了出去。“啪“的一聲,石子被摔他們跟前的江邊上,濺了男孩一身的水珠。。。

“你太差勁了“,男孩一邊擦着臉,一邊隨手拾起一塊石子,“看我的!”
石子在天空划了一道長長的線,消失在了江心。。。

女孩呆了一會,然後馬上低頭翻了兩個大小一樣的石子,把其中一個遞給男孩,“你等我擲完了再擲,看看你。。。“
”比你遠多少?“面對即將到來的挑戰,男孩顯然有點激動。

男孩話音剛落,女孩剛有點平和的臉馬上又綳了起來,她恨恨地向男孩瞪了一眼,轉身後卻調皮地笑起來“我不要你投近了,也不要你投遠了,我要看看你投到的地方離我投的落點能有多近。“

兩塊石子一前一後落到了江面,泛起了幾圈波紋,波紋一邊向外擴散一邊隨着江水蕩漾,不一會就從江面上消失了。。。

發表在 某時雨集 | 留下評論

Extreme Programming and Test-Driven Development

Extreme Programming
Extreme Programming (or XP) is a software engineering methodology, the most prominent of several agile software development methodologies.

Extreme Programming Explained describes Extreme Programming as being:
    * An attempt to reconcile humanity and productivity
    * A mechanism for social change
    * A path to improvement
    * A style of development
    * A software development discipline


Test-Driven Development
The goal of TDD is to write clean code that works.

What is Test-Driven Development?
Test-Driven Development (TDD) is a software development technique that involves repeatedly first writing a test case and then implementing only the code necessary to pass the test. Test-driven development is a method of designing software, not merely a method of testing.

In addition to normal “did it pass?” testing, you can go the opposite route. By testing your application where the weak points are, you can fix it before it ever becomes an issue.

Test-Driven Development Cycle
1. Add a test
In order to write a test, the developer must understand the specification and the requirements of the feature clearly.
2. Run all tests and see the new one fail
testing the tests
3. Write some code
It is important that the code written is only designed to pass the test; no further (and therefore untested) functionality should be predicted and ‘allowed for’ at any stage.

KISS
Keep It Simple, Stupid.
Everything should be made as simple as possible, but no simpler.
                    –Albert Einstein

You Ain’t Gonna Need It
‘You Ain’t Gonna Need It’(YAGNI), is a reminder for programmers that one should never add functionality until it is necessary.

4. Run the automated tests and see them succeed
5. Refactor code

Refactoring
A code refactoring is any change to a computer program which improves its readability or simplifies its structure without changing its results.
List of refactorings

    * Encapsulate Field(e.g. providing methods that can be used to read/write to/from the field rather than accessing the field directly.)
    * Extract Method (to turn part of a larger method into a new method. By breaking down code in smaller pieces, it is more easily understandable. This is also applicable to functions)
    * Generalize Type (to making more general or more abstract some subset of the traits of a specific type. An example of generalizing a type would be moving a method from a child to a parent class for common use by all the parent class’ children, not just the original child.)
    * Pull Up (moving a method from a Subclass into a Superclass. )
    * Push Down (moving a method from a SuperClass into a SubClass.)
    * Rename Method (changing the name of a method into a new one that better reveals its purpose).

The cycle is then repeated, starting with another new test to push forward the functionality.

"Test-Driven Development Mantra" is known as red/green/refactor where red means fail and green is pass.

Benefits
By focusing on the test cases first, one must imagine how the functionality will be used by clients (in this case, the test cases). Therefore, the programmer is only concerned with the interface and not the implementation.
It allows a programmer to focus on the task at hand as the first goal is to make the test pass.
Ensuring that all written code is covered by a test.

Limitations
A test-driven development is only as good as its tests.

Reference
http://en.wikipedia.org/wiki/Test-driven_development
http://en.wikipedia.org/wiki/You_Ain%27t_Gonna_Need_It
http://en.wikipedia.org/wiki/Refactoring

Related Resources
Test::Unit – Ruby Unit Testing Framework
A Guide to Testing the Rails
Test Driven Design for Ruby and Rails
Ruby, Rails, Test::Rails Cheat Sheet

發表在 Ruby on Rails | 標籤為 , , | 留下評論

開始支持男同性戀

最近在百度貼吧上經常看到有男人發求找同性伴侶的貼子。我一直對這個很反感。這反感來自好幾個原因
1.這樣的貼子到處都是。幾乎不管哪個分類下都可看到。這算廣告貼。即使發貼人對伴侶的要求多麼強烈,也無論他尋找的是同性還是異性,都不應該做發垃圾廣告這種不道德的行為。
2.這些“同性戀“者到處發貼,好像不是在找戀人,而是在找可以發生一夜情(一夜性)的
同性性伴侶。他們的行為給我同性性愛是一種可以隨便發生的性關係,我甚至懷疑他們經常隨便亂倫。
3.雖然我看過A片中兩個女性發生同性行為,但沒有,也不想看兩個男性發生性行為,甚至帶有傳統申美觀的我去想象那樣的場景都會感到無比的嘔心。

但今天我卻突然改變了想法。原因是大街上看到的很帥的女生帶着另一個女生。這是經常看到的場景,但今天好像我第一次去思考這個問題!李宇春!新時代到來了!如果我不時地遇到這麼帥的女生,這麼不帥的我不但不能追她,而且她還帶走了另一個女生!(帶走一個是樂觀估計,像李宇春不知道能帶走多少!),這樣我不但要同眾多的男生競爭本來有限的資源,現在還多了很帥的女生成為新的競爭對手!

在面對這個危難時我突然想起了百度上的那些男同性戀貼,猶如在黑暗中看到了幾點燈火!多一個男同性戀不就少於二個競爭對手嗎?於是我想大聲地呼籲:“你們去搞吧,我也開始支持你們了!!!“

發表在 某時雨集 | 一條評論

殺死那個人

戰國春秋,夕陽,大漠。
兩個武士一前一後地走着。前者中年,帶刀,後者帶劍,二十齣頭。前者越走越慢,後者窮追不捨。
“為什麼?”中年回頭向青年無奈地大叫。
“我 要 殺 你”青年用一種很平靜的口氣回答,沒有停下腳步。
“為什麼?”
青年沒有回答。
“為什麼!!!!???"中年看着不斷向自己走來的青年發瘋似的大喊。

青年還是沒有回答。這時中年已經在前面不遠,“拔 刀 吧“
中年搖了搖頭,發出一陣苦笑,繼續帶着疲憊的身軀前走。
“拔 刀 吧“青年平靜地重複了一遍。
中年還是沒有理會。但隨着一絲詭異的笑容,他臉上露出了殺氣,然後繼續慢慢前走,腳步輕了許多。
青年見中年不理會,停下了腳步,取出水壺,仰面喝水。
就在這時,飛刀,和中年的大刀前後緊隨而來。。。
夕陽下只見一身影閃動了幾下。。。
青年的臉上多了一道口子,而他的左手的劍穿過中年的身體,滴着鮮紅的血。。。
“這不是魯國的劍法!”中年不解。
“不 是”青年還是那樣的平靜,像什麼事都沒有發生一樣。
“你是哪人?”中年突然也平靜了。
“廣 東“
”你是從哪知道我的?“
”網 上“
”哦!“中年大悟,“是博客。。。我明白了。看來我的確不應該上傳那張照片!”
“是的 我見到那張帶淚的臉的第一刻就註定了你的死亡“
“為了這個,你追了我幾千里路?“
”是的 幾千里路和2000多年“
“就為了一個小女孩?”中年發出一陣冷笑。
“不 是為了我自己“,青年一邊慢慢地從中年身上拔出他的劍,一邊回答道,“為了在你那張照片前顯得如此無助和平庸的自己 “
“所以你要殺我?”
“是 的“,青年臉上還是沒有任何錶情。
“就算在自己的夢中?”
青年張口,卻沒能說出什麼。中年躺下後閉目了。
青年從中年身上扯下一塊布,一邊擦着劍一邊說出了含在嘴裡的話,“是的,就算在自己的夢中”。第一次,他的語氣顯得有點低顫。
擦完劍,青年起身向遠方走去。
夕陽下他的影子越來越長,直到化成鬧鐘的指針。

發表在 某時雨集, 蓋世武功 | 留下評論

Question-Driven Learning – the learning skill for information age

Question-Driven Learning(QDL) is an effective learning approach. It means learning by solving questions.

Learning was often taken before questions
At school, or university, learning often is done before the questions is given. At school, Questions(mainly included in the  homework) is given after students have the lesson. And, students attend the school, learn knowledge for years, and after they have graduated, they take jobs. This means they meet practical problems (questions) after the learning.

What is the problem with traditional learn method?
1. The knowledge or skills that are learned before you need may never have chance to be used.  Some may be out of range, (for instance — if you learned Computer Science before you become a English teacher), or some may be outdated (if you learned a Computer Skill before you get a computer related job, four years later).
2. The knowledge information have been growing very fast, especially in the last decades, with the help of computers and other information technologies. Information are exploding. There are just to much to learn before you meet real problem, when you don’t know what you really need.
3. If the question come from real life, not from text books or school teachers, you understand the question in a more realistic way, and as the question/problem either stop you from doing some thing, or by solving it you will get rewarded, you will pay more attention to it and try harder to solve it.
4. The skills and knowledge that are learned by doing, will be longer lasting in your memory.

How to do it?
When problems come, ask, search (google) the learn the related knowledge, come up ways to solve the problem. If the problem doesn’t be solved, ask, search and learn more, or skip this problem, deal with another (hope it’s an easier one), after time when by, more problems will be solved. And, always review the questions and solutions, think what you have learned from them, and if necessary, note them down.

And, Still, you need to Learn before the question!
Why? Because Question-Driven Learning has its weakness.
1. If you want to do something, and you meet tons of problems, and you have hundreds of questions want to ask, you should not ask  these questions, instead,  take a book about the subject,  perfectly  a basic, fundamental one, leaving the details behind, and understand this thing you want to do by reading/scanning the book. After you have a specific question about the subject, then you are ready to ask or search.
2. If you don’t know what to do, what to ask or what to search. Reading books or taking an essential course about the subject will be necessary.

發表在 成敗幾何 | 標籤為 | 留下評論

REST and ActiveResource

REST (Representational State Transfer)
REST is An Architectural Style
It uses the following standards:

    *  HTTP
    * URL
    * XML/HTML/GIF/JPEG/etc (Resource Representations)
    * text/xml, text/html, image/gif, image/jpeg, etc (MIME Types)
The Whole WWW is a REST system!

RESTful

RESTafarians

HTTP methods: PUT, GET, POST and DELETE.
database operations: CREATE, READ, UPDATE, DELETE (CRUD)

URI -> Resource
REST Is a Conversation
The verbs of the REST conversation are the aforementioned request methods, while the nouns are URIs, A URI should be only a pointer to a resource.
e.g.
GET "/books/1"
DELETE "/books/1"

URI,URL and URN
A Uniform Resource Identifier (URI), is a compact string of characters used to identify or name a resource.

A Uniform Resource Locator (URL) is a URI that, in addition to identifying a resource, provides means of acting upon or obtaining a representation of the resource by describing its primary access mechanism or network "location".

Uniform Resource Name (URN) is a URI that identifies a resource by name in a particular namespace. (e.g. urn:isbn:0-395-36341-1)

Web service, a software system designed to support interoperable Machine to Machine interaction over a network.

Remote Procedure Call (RPC)

REST Is Design
A clear approach to controller-design that’ll reduce complexity for the implementer and result in an application that behaves as a much better citizen on the general web.

REST gives us a framework for simple but extensible application design.

ActiveResource
RailsConf Keynote: David Heinemeier Hansson Video the World of Resources
online video: http://www.scribemedia.org/2006/07/09/dhh/
download address: http://downloads.scribemedia.net/rails2006/01_dh_hansson.m4v
(the slides http://www.loudthinking.com/lt-files/worldofresources.pdf)

David Heinemeier Hansson’s blog on ActiveResources
http://www.loudthinking.com/arc/000593.html

script/generate scaffold_resource

http://www.xfront.com/REST-Web-Services.html
http://en.wikipedia.org/wiki/Representational_State_Transfer
http://en.wikipedia.org/wiki/Uniform_Resource_Identifier
http://en.wikipedia.org/wiki/Web_service
Rails Cookbook

發表在 Ruby on Rails, 信息處理 | 留下評論

Web Services on Rails note

By Kevin Marshall

The Basics
APIs(application programming interface)

three architectures:
Representational State Transfer (REST)
Simple Object Access Protocol (SOAP)
Extensible Markup Language Remote Procedural(XML-RPC)
(SOAP grew out of XML-RPC)

SOAP
Web service signatures are really just data types that the service either expects or returns.
WSDL(Web Service Description Language)
a WSDL file is an XML document that defines the interface to a SOAP service.

REST
URL, http
The world wide web itself can be considered a REST system.

Searching Yahoo using REST
need:
1.Connect( net lib)
2.store
3.Parse results ( REXML lib)

Yahoo! web service API (up to 5,000 requests/IP per day)

Google AJAX Search API

use the CGI library to escape our search term, ensuring that the search term is safe for use in our HTTP GET request:
query = CGI.escape("SEARCH TEXT")

https://www.google.com/accounts/NewAccount?continue=http://api.google.com/createkey&followup=http://api.google.com/createkey:

Searching Google Using SOAP or SOAP with WSDL Files
UTF-8 can contain special characters that Ruby can’t handle in a string, causing our driver to throw an XSD::ValueSpaceError error upon invocation. To avoid this problem, we manually set our encoding to UTF-8 using the XSD library.
XSD::Charset.encoding = ‘UTF8′

Displaying Photos from Flickr Using XML-RPC

Building Web Service Servers
Make sure you turn off layouts for the methods you’ll be using in your service
Associate RXML templates with the methods in your controllers, instead of RHTML templates
xml is an XML document object that’s available in any RXML template
xml.name("Kevin", :id => 1, "age" => "31")
# creates <name id="1" age="31">Kevin</name>

 xml.exampledata do
     xml.name("Kevin")
 end
 # creates <exampledata><name>Kevin</name></exampledata>

SOAP and XML-RPC Web Service Servers
ActionWebService (AWS)
 script/generate web_service YOURSERVICE YOURMETHOD1 YOURMETHOD2

 three dispatching options, :direct, :delegated, or :layered.
web_service_dispatching_mode:direct
:delegated or :layered is the best way to go for any large or complex web service
With :delegated, clients use a distinct URL for each method in the API
With :layered, clients use the same URL for all attached methods and rely on AWS to route the request based on information passed in its header

:expects and :returns symbols
Ruby types (:string, :int, :bool, :float, :time, :datetime, :date, and :base64), or the names of ActiveRecord::Base or ActionWebService::Struct classes (for example, Greeting or Account), or a single element array to represent arrays of objects (for example, [:string] to represent an array of Strings or [Account] to represent an array of ActionWebService::Struct Account objects).

 raise "Access denied!"

發表在 Ruby on Rails | 留下評論

將日誌系統換成了typo

以前的日誌系統是基於asp+mssql的。功能上來說很滿足我的須要,簡單好用。即便這樣我也無時不刻想把它換成typo,經過幾天的努力,終於如願以償了。

為什麼要轉成TYPO?
typo基於Ruby on Rails語言,而自己正在學習使用ror,所以很希望在使用中熟悉別人的代碼寫作方法。而且typo可以在linux+mysql+apache的服務器上使用,我準備將使用更多的linux空間,最後去掉windows的服務器。所以我處心積慮地要轉向typo.

轉向typo

typo是為大多是國外在使用,國內很少用,原因是多方面的。1它要用到rails平台,現在比較難找到空間,2它的功能對國內用戶來說不友好,3它到目前只有英文版(4.1開始正在做多語言功能)。

換成typo時我做的第一步就是修改typo系統,
1.將typo和fckeditor整合,去掉textfilter的功能,這樣更方便我的使用習慣。
2.改進圖片上傳功能,使圖片上傳馬上顯示出來,這樣我就可以copy進fckeditor去,而不用寫代碼引用圖片。
3.修改鏈接顯示樣式,本來想改成和原來的blog系統一樣,但發現原來的blog使用html後綴,現在所有html文件被過濾了,所以只能改成大概和原來的鏈接一樣。
4.本來想找個好看點的theme,但找來找去竟然沒有一個讓人滿意的,這時懷念起來原來的界面,於是改!將原來的界面搬到了typo上!

比較費時的是數據轉換,寫了個程序轉換,現在轉過了所有的文章(個別文章的站內鏈接還有點問題),對文章分類進行了整理(typo支持一篇文章同屬於多個分類)。所有的評論沒有轉換,還好本來評論就不多。

發表在 其它 | 留下評論

MirrorMask, 2005

MirrorMask, 2005
http://www.imdb.com/title/tt0366780/
一部充滿幻想的英國電影。畫面真是太奇幻了,可惜的是故事沒有一點新意。
6


不知道這是哪裡,看起來不錯的地方。

發表在 電影評論 | 留下評論