- 论坛徽章:
- 0
|
我曾经也是理论派,一动手写代码首先是封装基本的数据结构、函数。直到有一次一位级别很高的Arch看了我的代码后问我:你为什么不直接用glib?我回答是为了移植方便。Arch告诉我直接用,但没说原因。我只好照办了。后来慢慢感觉到:
1、在开始动手时就把目标定得太高,会给你带来很多麻烦,考虑移植性往往让你举步维艰
2、community的人喜欢看到他们熟悉的库函数,而不是你自己的封装,特别是在你封装后的函数名称与众所周知的库函数名相去甚远时
3、你的程序99%的时候是运行在你所用的平台的,例如linux。
4、等你的项目名动社区时,比如集成到了各大Linux发行版中,再慢慢修改代码成可移植的版本也不迟。
5、不要以“等成熟后修改,代码量太大了”为借口,fedaro总共2000多个包,上10w行代码的项目没有几个
6、开始做的适合,只要架构设计得当,则以先完成功能为主
7、openssh的方式也不错,即有一个平台特定的版本,也有一个可移植于各平台的版本。虽然我个人认为openssh的代码很烂,但我同意它主页上的话:
OpenSSH is developed by two teams. One team does strictly OpenBSD-based development, aiming to produce code that is as clean, simple, and secure as possible. We believe that simplicity without the portability "goop" allows for better code quality control and easier review. The other team then takes the clean version and makes it portable (adding the "goop") to make it run on many operating systems -- the so-called -p releases, ie "OpenSSH 5.3p1". |
评分
-
查看全部评分
|