引言

项目进行中不可避免的两件事就是:

  • 对代码的升级,修改
  • 对存储结构的升级,修改
  • Erlang在设计之初就对此两件事进行了考虑,完全实现热升级。

    Erlang的代码热替换特性

    最近在做Live chat的项目, 基于Ejabberd开发。Ejabberd的模块管理显示了Erlang的代码热替换的特性。可以在不重启Ejabberd服务器的情况下进行模块级别代码的升级或者修改。并且Ejabberd管理界面提供了模块升级或修改的管理功能。假如需要升级某个模块,只需要将编译好的文件替换原来的文件,进入管理后台,进行升级操作。

    对于PHP之类非编译类的语言,我们在需要修改代码的时候,可以直接将旧代码替换为新代码实现平滑升级,但是对于JAVA、C++之类的项目则需要停机更新。Erlang的这个特性是编译型语言的一大改进。

    Mnesia如何修改现有的表结构

    Mnesia是Erlang内置的分布式数据库。可以用内置函数进行数据库的操作或者用QLC进行数据CURD。我们都会经常遇到项目功能的升级,需求的增长,不可避免需要对原有的数据结构进行修改。

    Mnesia提供了transform table的功能。假如不需要保留原有数据可以进行如下的数据库表的结构更新:

    对于PHP/java 项目,一遍表结构都是自己设计,可以直接修改Mysql的表结构,同时对涉及代码进行更新。对于不同的PHP开发框架来说,有不同的流程,有些PHP开发框架内置了ORM特性,数据结构的修改很容易。假如没有类似特性则需要review所有的相关代码,进行修改。好在当今框架泛滥,找到合适的开发框架很简单。Python的Dojango框架由于受到Raise的影响对持续迭代开发做了很多考虑。

    在此提及Drupal数据库表结构的更新,Drupal中一般用CCK做为字段管理工具。他有一个特性既是会自动的将多个相同类型的字段合并为一张新表, 但是假如此类型的字段只有一个则会存储在content表中。假如深入做Drupal开发,需要直接用SQL操作数据,不了解此特性会出很多错。

    One big problem i thought recently relates on the user experience and user usability. User interface is very important in online business. Your client is kept out of your door just because of you did not pay more effects on the usability. Poor usability leads poor ROI. That is the key element why your business grows slow. But it always not too late to improve the usability of your web site.
    So i added a category on my blog. Keep an eye on user interface design.

    Key points to improve the usability:

    * Keep clean and simple

    * Less colors, but more contrast

    * Bigger font

    * Split different area by edge or space

    Good usability examples:

    Install VMware under windows as the development environment.
    IP settings:

    VMware provides:bridge,Host Only and NAT 3 ways. I think NAT is the best way to go:

    1. VMware network adapter chosing NAT.
    2. Edit=>virtual network editing=>NAT,NAT gateway ip address is 192.168.X.2
    3. Under windows ipconfig to see the ip address of VMnet8, is 192.168.X.1
    4. Set the ip address to be 192.168.X.55/255.255.255.0
    /etc/network/interfaces
    5. vi /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    ONBOOT=yes
    BOOTPROTO=static
    IPADDRESS=192.168.X.55
    NETMASK=255.255.255.0
    GATEWAY=192.168.X.2

    6. /etc/init.d/network restart

    Domain setting:
    Edit C:\WINDOWS\system32\drivers\etc\hosts Map the domain and the VM ip address.

    Share folder setting:
    Insert the linux.iso to the CDROM of VM. Install the tools.
    ./install.pl
    Choose VM > Settings > Options and click Shared folders.
    And your folder of windows will local in /mnt/hgfs/share