/曾强/.match(Zeng Qiang)

Another mobile and web developer

Dealing With Version Number

I have not created any software in a serious production environment before, thus, no experience on how to name version numbers. My current project is the first time I deal with it seriously, and I find it quite interesting.

Version number marks each iteration of the development. Most of the time, it’s composed of several parts that convey different informations. For example, the number below:

0.2.31

The number is separated by dots. So there are 3 numbers here, 0, 2, 31.

Android Dev Note 1

Coding android application is always an enjoyable process for me.

I find the following stuff intrigued me a lot.

Self-contained activity and task stack

As a mobile OS, android is very memory-conservative. In android, the basic building block of an app is an Activity. (there are 4 components consisting an application, but obviously Activity is most used and important component).

Activities are launched in sequence and their states are recorded down by the OS into a task stack. The task stack follows the rules below: (these are incomplete rules, but are those I think is important for newbie Android Developers)

IBM Worklight

This is an article followed by a training given by IBM worklight team.

What is worklight?

Worklight is an end to end mobility solution covering app development and mobile application management.

It consists of 5 components, namely worklight studio, worklight server, worklight runtime, worklight console and applicaiton center. The descriptions of each are available online. I just want to share my understanding and evaluations on this technology.

API Is Very Important

I was reading coolshell.cn tonight. The author refers to the chapter of modularity in the book The Art of Unix Programming as the most charming chapter. Thus, I searched and read it. When I read the following, I couldn’t agree more with the book:

The APIs between modules have a dual role. On the implementation level, they function as choke points between the modules, preventing the internals of each from leaking into its neighbors. On the design level, it is the APIs (not the bits of implementation between them) that really define your architecture.

It reminds me an argument with a senior java engineer happened a while ago.

Styling in Android

Android Development team tries to make styling applications as easy as styling a web page. We can change the look and feel of every element within the application. For example, the background of textbox, the background of action bar, or the shape of a button. The android styling also has the feature of heirachical inheritance of styles. If the application use one style, while the activity use another, the activity’s will overwrite the applications. This rule applies up to every view group and single element. This allows easy reuse of styles. The developer only needs to overwrite the style needed.

The major source of reference about styling is at here. But it doesn’t give out a detail documentation on which style applies to which element. Instead, it only gives two system styling files that contains whole bunch of xmls for major system styles, that is holo and holo white. The links is styles.xml and themes.xml. I need to dig into the lines and try out several styles before I can find the one needed. Though it’s a bit troublesome, but it’s not difficult at all.

Understanding Backbone 1

I started using backbone in my project to build a portal for admin users. It’s my first attemp using backbone seriously, though I have played with it for quite a while.

In backbone, the entry point of the application is Backbone.history.start().

This function takes a hash as argument, which consist of a html5 feature called pushState. Setting this attribute to true can let backbone use normal url style in the form of “/page1/page2”. Otherwise, the url of backbone pages have to be in the form of “#page1/page2”. But this is only supported in the html5 capable browsers, specifically excluding IE8. So I just use it without pushstate by leaving arguments blank.

I have to define a router object before the page load. The router is like ruby on rails routes, but significantly simplified. This is my router:

About Authentication

这篇文章记录一下我对验证浅薄的认识。

身份认证是网络应用真非常重要的一个部分。通常我们做认证的目的有两个

  1. 确认请求发送者身份
  2. 授权用户资源给第三方应用

这里主要说的是第一种。

最简单的情况是用户名和密码验证。客户端让用户输入用户名和密码,然后发给服务端进行验证。服务端在数据库里通过用户名找到被加密的密码。然后用相同方式加密收到的密码并跟数据库密码比较,如果相同就验证成功。验证成功后,服务端会生成一个会话对象并保存在服务端。这个会话的id会作为验证的结果返回给客户端。返回方式是把sessionid加在在http response header里的”set-cookie:“项。 客户端一般将这个id储存在cookie里面(浏览器会自动处理),并在接下来跟服务器的交流中都会将这个cookie附带在header中发给服务端。服务端以此来得到会话对象以及相应的状态。

这里有几点要说说。

首先是加密哈希的区别。 加密是使用一个密钥和一定的算法算法将明文转换为一个字符串的过程。这个字符串是可以转换回去的。现在有的算法比如说对称的AES,非对称的RSA。 哈希码也是将明文转换成字符串的方法,但它是单向的,目前有的算法比如说,md5和sha1

对于密码,一般能不存就不存,如果存就一定要哈希。md5, sha1都不是很安全, 但一般大家还是会用sha1。

在ruby 里面生成sha1很简单

1
2
require 'digest/sha1'
Digest::SHA1.hexdigest 'foo'

2-legged vs. 3-legged OAuth

Published on January 10, 2011, by cakebaker

From emails I receive it seems like there is a bit of confusion about what the terms 2-legged OAuth and 3-legged OAuth mean. I hope I can clear up this confusion with this article (and don’t contribute more to the confusion…).

In short, they describe two different usage scenarios of OAuth involving two respectively three parties.

3-legged OAuth describes the scenario for which OAuth was originally developed: a resource owner wants to give a client access to a server without sharing his credentials (i.e. username/password). A typical example is a user (resource owner) who wants to give a third-party application (client) access to his Twitter account (server).

Using the Rake Build Language

by Martin Fowler on August 10, 2005, link: http://www.martinfowler.com/articles/rake.html

Rake is a build language, similar in purpose to make and ant. Like make and ant it’s a Domain Specific Language, unlike those two it’s an internal DSL programmed in the Ruby language. In this article I introduce rake and describe some interesting things that came out of my use of rake to build this web site: dependency models, synthesized tasks, custom build routines and debugging the build script.