摘要: struct NoCaseCompare : public std::binary_function<std::string, std::string, bool>{ static bool cmp(char c1, char c2) { return toupper(c1) < toupper(c2); } bool operator()(const std::string& s1, const std::string& s2) const { return lexicographical_compare(s1.beg... 阅读全文
posted @ 2012-03-09 23:29 chengfei164 阅读(171) 评论(0) 推荐(0) 编辑
摘要: IntroductionC++ is a strongly typed compiler language. Though not as strongly typed as ADA, a C++ compiler will complain if you try to assign an object of one type to an object of another type (if there is no acceptable conversion). Obviously, this requires that the compiler knows all available type 阅读全文
posted @ 2012-03-05 12:53 chengfei164 阅读(212) 评论(0) 推荐(0) 编辑
摘要: socket API:工作在不同层面上的socket实际上,Linux内核只提供了一个与套接字相关的系统调用,即sys_socketcall,应用程序的所有套接字调用都会映射到这个系统调用上Linux网络核心数据结构是套接字缓存(socket buffer),简称skb。它代表一个要发送或处理的报文,并贯穿于整个协议栈。1、 套接字缓存skb由两部分组成:(1) 报文数据:它保存了实际在网络中传输的数据;(2) 管理数据:供内核处理报文的额外数据,这些数据构成了协议之间交换的控制信息。当应用程序向一个socket传输数据之后,该socket将创建相应的套接字缓存,并将用户数据拷贝到缓存中。当报 阅读全文
posted @ 2012-03-02 17:53 chengfei164 阅读(521) 评论(0) 推荐(0) 编辑
摘要: 原文: http://blog.sina.com.cn/s/blog_70c9335b010125l7.htmlA quick briefing about myself - I joined Facebook in early 2007 and have been through many challenging projects. A lot of problems were new and unseen. A lot were above the scale history has ever seen. A lot of hard times but also great times. 阅读全文
posted @ 2012-03-02 12:12 chengfei164 阅读(114) 评论(0) 推荐(1) 编辑
摘要: 原文链接:http://bbs.chinaunix.net/thread-2055231-1-1.html1. 内核初始化: *内核建立好内核页目录页表数据库,假设物理内存大小为len,则建立了[3G--3G+len]::[0--len]这样的虚地址vaddr和物理地址paddr的线性对应关系; *内核建立一个page数组,page数组和物理页面系列完全是线性对应,page用来管理该物理页面状态,每个物理页面的虚地址保存在page->virtual中; *内核建立好一个free_list,将没有使用的物理页面对应的page放入其中,已经使用的就不用放入了;线性映射简化了内核中虚拟地址和物 阅读全文
posted @ 2012-03-02 09:48 chengfei164 阅读(354) 评论(0) 推荐(1) 编辑
摘要: 5 Guiding Principles for Experience Designers1. Understand the underlying problem before attempting to solve itYour work should have purpose—addressing actual, urgent problems that people are facing. Make sure that you can clearly articulate the core of the issue before spending an ounce of time on 阅读全文
posted @ 2012-02-22 21:03 chengfei164 阅读(169) 评论(0) 推荐(1) 编辑
摘要: command模式还是很清晰明了的:我这里想说的是order的实例是怎么从client传递到receiver的。 如果client和receiver是在一个进程里,自然无需多言。但如果这是一个分布式的系统呢?我想一般的处理应该是用持久化,把order实例序列化成xml,当作消息从client端发送到receiver端, receiver端根据xml描述生成object实例,执行然后删掉。这个过程我没实际做过,我现在work on的系统是这么处理的:首先,这个系统有自己的UI和逻辑层的同步机制,UI和逻辑层是两个独立的进程,可以部署到一台机器或者不同的机器上。所有在逻辑层的对象在UI层都有自己的 阅读全文
posted @ 2012-02-22 18:14 chengfei164 阅读(705) 评论(0) 推荐(1) 编辑
摘要: 不要光考虑class之间的继承关系,有时候包含关系也能派上大用场。考虑以下场景,ThreadScheduler类,既要考虑不同的调度方式,还要考虑到不同的操作系统平台。如果按继承关系来设计,如下图,最后派生出来的子类的数目是N1×N2, 其中N1是不同调度方式的数目,N2是不同操作系统平台的数目如果考虑到以下事实,在每个子类里,有一部分逻辑只是和平台相关的,而和具体的调度方式无关。那么这种设计显然的会产生很大的代码重复。自然的,我们可以把平台相关的逻辑单独的拿出来Use the Bridge pattern when:you want run-time binding of the 阅读全文
posted @ 2012-02-22 13:50 chengfei164 阅读(224) 评论(0) 推荐(1) 编辑
摘要: 先说说我对REST的理解,在REST之前,web service的设计方法主流应该是SOAP,我觉得SOAP一定是那些搞C++/C#的人设计出来的,因为SOAP思考问题的着眼点是如何把之前已有的系统搬到web上去。而REST的理念更有方法论的味道,更贴合web应用的实际。关于REST的介绍,推荐下面这篇文章:http://www.xml.com/pub/a/2004/12/01/restful-web.html就像文章里说的,为你的web应用设计REST风格的API,只要思考并回答以下4个问题:What are the URIs? (everything in your system is r 阅读全文
posted @ 2012-02-19 23:31 chengfei164 阅读(455) 评论(0) 推荐(1) 编辑