落第秀才

秀才出远门,关天下P事?

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  2 随笔 :: 0 文章 :: 0 评论 :: 0 引用

公告

2007年8月10日 #

I noticed an interesting statement when skimming through Windows Workflow Foundation Hands-On Lab code, it looks like:

public int amount = default(System.Int32);

Now I feel a little bit not comfortable  with the "default" here. Look it up (from MSDN):

In generic classes and methods, one issue that arises is how to assign a default value to a parameterized type T when you do not know the following in advance:

  • Whether T will be a reference type or a value type.

  • If T is a value type, whether it will be a numeric value or a struct.

Given a variable t of a parameterized type T, the statement t = null is only valid if T is a reference type and t = 0 will only work for numeric value types but not for structs. The solution is to use the default keyword, which will return null for reference types and zero for numeric value types. For structs, it will return each member of the struct initialized to zero or null depending on whether they are value or reference types.

Now it starts to make sence why I don't feel very right here...

Copy a question from thescripts.com, maybe a good question for your next interview:

What's the difference among the following statements?

int x = default(int);
int x = 0;
int x = new int();

posted @ 2007-08-10 07:34 落第秀才 阅读(137) 评论(0) 编辑

2007年2月3日 #

Developing a basic mapping solution online was made easy, thanks to the release of google/yahoo mapping. However, both g/y mapping limits the geocode calls with some strict rules. For U.S addresses, there's a good replacement: geocoder.us. It's totally free and is easy to use. If you are using a commission-based mapping service that is charging you on your geocoding hits, this service might be useful.

The examples from the website are staightforward. I spent half an hour yesterday and finished a simple geocode library. One of the interest points is that it supports asyn callbacks, which makes it easier to play a little bit of AJAX.

The biggest con is that the system is built upon Tiger Mapping Service (tiger.census.gov/instruct.html). As geocoder.us states: the TIGER/Line data set is notoriously incomplete. So it happens if some good addresses are not found. My suggestion is that a tiered geocoding logic be used in the application.

I will be working on a free/share ware based on some GIS technologies in the next few month. Feel free to contact me if you are interested.
posted @ 2007-02-03 00:56 落第秀才 阅读(66) 评论(0) 编辑