月度归档:2010年04月

转载:柔弱和刚强

原文地址:http://blog.sina.com.cn/s/blog_493a84550100i60r.html

在《道德经》里面谈到水之七善,水以柔弱胜刚强,不争而善胜的道理。柔弱和刚强本身并没有明确的界限,更多的时候还是刚柔相济,相互补充,遇刚则柔而以柔克刚;遇柔则刚而英明果断。

柔弱并不是软弱,而是一种谦德和处下的品质,海纳百川,有容乃大。柔弱是一种理解和包容,去我和利他,一种可持续的绵绵之力,厚积薄发,一方面是借势,一方面是不战而屈人之兵。而刚强也不是乱用蛮力,而是一种积极和果断的决策,一种对时机的把握。

外柔而内刚,外圆而内方都是一种境界。内刚需要的是一种自我的信念和价值观,需要的是内心的强大,如果没有内刚的支持就很容易走向软弱和灰心丧气。而刚强又需要把握有度,而不是乱用,孔子说过,到了壮年,血气旺盛刚烈,要戒争斗,因此更需要一种平和心态的修炼。

在团队里面开放和包容也始终是最重要的,不可以争强好胜,也不可以软弱而无主见。需要的只是积极学习的心态,既不能得理不饶人,也不能处处随波逐浪而无法体现自我价值。

Linux column命令详解

column命令用于格式化列信息。

column命令的使用格式如下:

column [-tx] [-c columns] [-s sep] [file ...]

常用的选项

-c      Output is formatted for a display columns wide.

-s      Specify a set of characters to be used to delimit columns for the -t option.

-t      Determine the number of columns the input contains and create a table.  Columns are delimited with whitespace, by
        default, or with the characters supplied using the -s option.  Useful for pretty-printing displays.

-x      Fill columns before filling rows.

样例

$ mount | column -t

/dev/root                 on  /      type  ext3   (rw)
/proc                     on  /proc  type  proc   (rw)
/dev/mapper/lvmraid-home  on  /home  type  ext3   (rw,noatime)

转载:10 tips to help avoid developer burn out

原文地址:http://www.diaryofaninja.com/blog/2010/04/13/10-tips-to-help-avoid-developer-burn-out

So we’ve all read posts like these probably a million times. I’ve recently been getting close to burn out in my current position, as we have had incredible amounts of work on. These are the things that I have found helped me. You may find variations on the theme but I thought it was important to get the conversation started, so that if anyone out there is feeling the same way i was, and is looking for potential answers, I’d be able to give them some ideas.

ZenGarden 1. Give your self some time alone(给自己一些独处的时间)

This is probably the most important. It affects your interactions with others ( including family ) and also affects your self image. One to two times a month unplug completely. Unplug from technology by leaving your phone at home. Unplug from everyone around you that is always there (your wife, flat mate, whatever).

Go somewhere that you enjoy and spend some time doing something on your own, whether it be fulfilling a hobby, laying in the beach, excercising or reading a book ( non IT related ) it’s important to have some wind down time for you, kind of like nap time in pre-school. All that’s important is that you forget about everything and reconnect with who you are, what your about, and what you want from life without all the "noise" of life hustling and bustling around you.

2. Find interests out of IT(在IT之外找到兴趣爱好)

Depending on the type of person you see yourself as you may have interests out of IT already or you may have none. Either way it is good to stop and have a look at the world around you, and find something else to add to your life.

3. Read things that aren’t IT related(阅读IT无关的内容)

Reading has many benefits. It can empty your mind, take you to places you’ve never been, let your imagination run wild and makes your written and spoken grammar/spelling better.  If you stay away from books about new programming languages, or the secrets to some new design pattern, you should be good.

Even reading the paper on a Sunday can contribute to this. Finding things that pull your interest in and keep it is the thing to aim. If your into scifi, history, biographies or the latest John Grisham, make sure your not simply forcing yourself to slog it out reading something that doesn’t interest you.

4. Eat healthy(健康饮食)

This can be harder for some people than others. Eating healthily has many benefits, and I’m not talking about the ones that fitness trainers rave on about. By eating foods with extra iron, protein and carbohydrates you can considerably change both your level of productivity/mental alertness, as well as stopping you from getting tired earlier in the day.

Sometimes just the feeling of constantly being tired can make you feel burnt out on it’s own, and this can lead to a negative  feeling towards your job, as your usually coming home from it tired. If you are feeling burnt out because you’re feeling tired at the end of the day, checking your diet can help a lot. Adding more fruit, as well as making sure you get breakfast everyday (even if it’s just some toast) contributes nearly instantly to a better feeling of well being.

5. Exercise regularly(定期锻炼)

Exercise, like your diet will help to keep you alert as well as reducing your stress levels. You’ll notice that a lot of successful people both in and out of IT make a special effort to try and stay active.

It’s important to note that if your not a very active person, that this needs to be approached from a confidence building excercise prospective.

Don’t try and run a marathon(不要尝试跑马拉松).

Set yoursef simple achievable goals and start by aiming low. If you tell yourself you’re going to walk around the block for 10 minutes a day you achieve two things: you have a goal that you’re easily going to achieve, so you won’t feel like it’s a burden "it’s only 10 minutes" while at the same time you get a feeling of well being by achievig a goal you’ve set yourself. Make the goal harder every day/week and before you know it you’ll be both fitter and happier.

6. Attempt to set and achieve goals(努力为自己设定和实现目标)

As said above about excercise, achieving things you’ve set yourself will contribute greatly both to your self confidence and your overall life. By sitting down and thinking of things you want to do, and setting into action ways to achieve them you’ll feel great. Want to be better at something? Want to achieve positive change? Sit down and work out what you want, and go get it. This sounds cheesy but will work.

7. Give something back to the community (online or offline)(回馈当地的社会和开源社区)

Giving your time can be a great re-energizer. Whether it is by contributing to an open source project or giving your time to a local charity/school/church giving can be very rewarding. If open source I suggest you try with simple tasks first like bug fixes or documentation, as starting your own OS project can actually do the opposite and make you feel agressively "unloved" for your efforts.

8. Take planned short breaks at work(在上班的时候有计划地短暂休息)

This one is pure gold. If you work near any shops, or are in the CBD, get up from your desk and walk to pick something up. Whether it may be an afternoon coffee or a snack, just getting away from your desk for 10 minutes can make the difference between a brain made of mush after work and having the endurance to power on.

9. Take short breaks away from work(短期休假)

Everyone longs for a holiday, but not all of us have time. Getting away from work and getting some perspective can make all the difference. The trick is to lock it down from a distance – If you don’t have time to think after a long day you need to plan well in advance. If your short on time go away for just a weekend but go away somewhere ( get out of the city ).
The advantages of organising in advance are many fold but just some of the reasons this is a great saviour :

  • By organising in advance you have some light at the end of the tunnel. Your working towards an endpoint. This stops you feeling bogged down.
  • You will probably be able to get cheaper everything in your mini holiday ( accommodation, flights etc )
  • You won’t have to explain yourself to your bosses etc. as it’s a done deal. I know of plenty of work places in this post recession era that will happily turn down leave if requested. Asking for time off in anticipation is like asking your bosses if they want to go without you for a time. In a lot of cases the answer to this is never going to be yes. A passive agressive stance of already having he trip away booked leaves little room for the answer no.

If this last one is the case though I may suggest number 10 as an option. Life is too short to work in a crap place of employment.

10. Consider another job or career(考虑其他的工作和职业)

Lastly sometimes it’s just time to move on. Whether it be to a new job or even a new career. A fresh slate may be all you need to reenergise yourself and your life. While this may seem like a very big move, it may be just what you need. Jobs come a long, times change. Life is too short to stay unhappy.

Daniel-Journey Weekly Dose-2010/4/16

Database & SQL

如何应对表结构经常变化?

第一种方法,预留字段.不管怎样,预留字段的方式还是很解决很多问题的,而且基本不影响性能,除了额外的meta信息描述外,也没有其他的负担。

第二种方法,使用复杂字段.使用复杂字段的好处就在于比较灵活,同一类型的数据可以放在一起(实际上相当于把应该是一个关联表的数据放一个字段里了),操作的性能也不错,但是复杂字段里面的内容查询比较困难.

还有一种方法,将数据的存储和索引(需要查询的内容)分开存放,相当于主表就一个key-value,value就是一个大的xml(或者其他的一坨),把需要查询的字段放到其他单独的表里去,可以参考friendfeed如何使用mysql.

还有column based db,也可以很好的解决这个问题,实际上他就本本回避了加字段的问题,不过现在似乎没有性能很好的实现

公交车路线查询系统后台数据库设计–查询算法

公交车路线查询系统后台数据库设计–关联地名和站点

SOA

SOA(面向服务的开发) 简介

微软SOA平台体系架构介绍

SOA@eBay 读后感

SOA与服务识别

面向服务架构(SOA)已被作为一种通过对齐IT和业务来促进业务机动性的方法被广泛接受。这种方法的主要不同之处在于,用相对较低的成本就能轻易 地获得某种机动性。在较高的层次,该方法试图将第n次业务变更所产生的增量成本降低到零或接近于零。组织推行SOA项目目的就是为了在他们的SOA之旅当 中尽早达到这个难以捉摸的第n个迭代。在实践中,要达到这种最佳状态的时间可能得花数年,甚至更长时间。

Architecture & Design

探秘:AOP能否解决紧密耦合的难题

虽然动态横切(其中对象的运行时行为可以改变)被认为是AOP的根基之一,但静态横切却是一种远不为人所知的技术。

Scalability

大规模集群下的http 状态解决方案

Java

Java 语言中的函数编程

Jrebel原理剖析

Reloading Java Classes 401: HotSwap and JRebel — Behind the Scenes

Difference between HashMap and IdentityHashMap

Linux

关于cronExpression的介绍

其他

我在QQ邮箱的这四年(一) [转]

张小龙(Foxmail的作者)认为互联网团队中的管理不是管人,而是管理产品体验,以产品体验为核心,产品设计和开发人 员与产品共同提升,共同进步。小龙之于QQ邮箱的影响正如乔布斯之于苹果的影响。

当时(2005)的javascript代码有很重的面向对象的味道,用传统的软件工程思想构建了 整个web框架,从软件的开发流程来说,这并没有什么问题,但是产品却有很大的问题出现了–慢,不是一般的慢,当时除了较快的电信网用户可以登陆进邮箱 之外,其他的用户基本上都被卡在登陆上。06年的大部分时间,整个团队都在解决速度慢的问题,尝试了很多方法,把js容量压缩掉了一半,js混淆之后又压 缩了很多,js文件分开为多个,但始终没有根本的转变,速度的提升仍然不能被用户接受。现在回过头分析这个问题,我觉得物理上的压缩和分割js文件之所以 解决不了问题是因为问题的根本在于js的逻辑架构上,当时的js有明显的基类和继承类结构体系,这种结构并不适合物理上的分割,即使分割开,渲染消耗的时 间是节省不下来的。

Javascript

实用的JavaScript 测试及效验工具

Daniel-Journey Weekly Dose-2010/4/11

Architecture & Design

Mediator Pattern applied to Javascript

The diagram below is a general representation of the interaction between a mediator and colleagues. Each colleague stores a reference to the mediator and the mediator stores a reference to each colleague. Colleagues are unaware of each other and messages are broadcast through the mediator.

image

Two of the benefits of using the Mediator pattern are that that it decouples colleagues and simplifies object interaction. Instead of using the Observer pattern to explicitly set many-to-many listeners and events, Mediator allows you to broadcast events globally across colleagues. The biggest drawback of using Mediator pattern is that due to the centralized control, the mediator can become difficult to manage.

向对象开发与面向组件开发的区别
养成面向组件编程(COP)的习惯
面向组件还是面向对象

既然类和组件有着这么多类似的地方,那么传统的面向对象编程和面向组件编程有什么区别呢?简单的说,面向对象关注的是组合在一个二进制可执行文件中的各个类的关系,而面向组件的编程关注的是在彼此独立的基础上模块之间的交互性,这种交互性使得你并不需要熟悉它们内部的工作原理。

面向对象与面向组件小议

面向对象技术的基础是封装--接口与实现分离,面向对象的核心是多态--这是接口和实现分离的更高级升华,使得在运行时可以动态根据条件来选择隐藏在接口后面的实现,面向对象的表现形式是类和继承。面向对象的主要目标是使系统对象化,良好的对象化的结果,就是系统的各部分更加清晰化,耦合度大大降低。 

组件技术的主要目标是复用--粗粒度的复用,这不是类的复用,而是组件的复用,如一个dll、一个中间件,甚至一个框架。一个组件可以有一个类或多个类及其它元素(枚举、)组成,但是组件有个很明oo显的特征,就是它是一个独立的物理单元,经常以非源码的形式(如二进制,IL)存在。一个完整的组件中一般有一个主类,而其它的类和元素都是为了支持该主类的功能实现而存在的。

最后强调一点,组件的目标是粗粒度的复用,组件的核心是接口。

用Qi4j进行面向组合编程

Java

SortedMap JavaDoc

Database and SQL

Efficient Pagination Using MySQL

高效的MySQL分页

SOA

服务和耦合的真正意义

基于设计的组件:首先:SOA和基于设计的组件不一样。在一个SOA架构中的服务是分布式的。而基于设计的组件中的这些组件是代码片段,通过他们所处每个系统来打包这些片段。从这种意义上来讲,EJB 能够作为服务和组件。

基于重用的组件通常比基于重用的服务简单。在服务重用时,在重用组件中变更带来的影响更是难以控制。其中可能有使用我的服务以及我没有关注的系统。在组件中,也许也是这种情况,但每个系统不得不有意识的做决定来升级组件,所以在一个系统中任何意外的破坏都与系统中那个早期的变更有关系。

耦合:这是“耦合”的真正意义。如果一个系统的改变很可能需要另一个系统的改变,那这两个系统是紧耦合的。这是一个很难通过观察代码来衡量的标准,然而很多人相信可以用代码的度量来理解耦合。

其他

一个老程序员的感悟:做技术二十多年,突然明白的道理

NO SQL Reading

That No SQL Thing – Key/Value stores

The simplest No SQL databases are the Key/Value stores.

Concurrency –In Key/Value Store, concurrency is only applicable on a single key, and it is usually offered as either optimistic writes or as eventually consistent. In highly scalable systems, optimistic writes are often not possible, because of the cost of verifying that the value haven’t changed (assuming the value may have replicated to other machines), there for, we usually see either a key master (one machine own a key) or the eventual consistency model.

Queries – there really isn’t any way to perform a query in a key value store, except by the key. Even range queries on the key are usually not possible.

Transactions – while it is possible to offer transaction guarantees in a key value store, those are usually only offer in the context of a single key put. It is possible to offer those on multiple keys, but that really doesn’t work when you start thinking about a distributed key value store, where different keys may reside on different machines. Some data stores offer no transaction guarantees.

Scaling Up – In Key Value stores, there are two major options for scaling, the simplest one would be to shard the entire key space. That means that keys starting in A go to one server, while keys starting with B go to another server. In this system, a key is only stored on a single server. That drastically simplify things like transactions guarantees, but it expose the system for data loss if a single server goes down. At this point, we introduce replication.

Replication – In key value stores, the replication can be done by the store itself or by the client (writing to multiple servers). Replication also introduce the problem of divergent versions. In other words, two servers in the same cluster think that the value of key ‘ABC’ are two different things. Resolving that is a complex issue, the common approaches are to decide that it can’t happen (Scalaris) and reject updates where we can’t ensure non conflict or to accept all updates and ask the client to resolve them for us at a later date (Amazon Dynamo, Rhino DHT).

That No SQL Thing – Key / Value stores – Operations

复习Amazon Dynamo设计的一点分享

Eventual consistency其实是对一致性的一种延展,过程中允许部分不一致,但是在事务处理结束或者有限的时间内保持事务的一致性。一句话简单概括就是:“过程松,结果紧,最终结果必须保持一致性”。

load balance的几种模式

客户端实施load balance。采用客户端包来实现分发算法,同时配置分发节点情况。Memcached Cache客户端使用的一种基本方式。

b. 服务端硬件实现load balance。

c. 客户端改进模式。配制节点以及算法都可以采用集中的Master来管理和维护,包括心跳检测等手段由Master来实现。当然支持Master失效的容错性策略实施。

d. 服务端模式改进。采用preference list来分离接受和处理任务的节点。

首先采用A模式可以防止B模式在单点的情况下出现的不可用风险,也可以减轻高并发下单点的压力,提高效率(这点淘宝的同学有和我提到过,他们采用的“软负载”方式)。但是A模式会增加对于客户端包的依赖性,对于扩展和升级都会有一定的限制。

其次B模式是最省心的方式,扩展性也比较好,但是就是在上面提到的单点问题会有所限制。

C方式是对于A方式的一种改进,我以前的一篇文章中提到过,这样可以提高A的可扩展性以及可维护性,减小对于客户端包的依赖,但是增加了系统复杂度,同时Master也是会有单点的问题,不过问题不大(失效的情况下就是退化到了A模式)。

D方式是解决服务端简单的分发而导致处理的不均衡性,其实这种模式也可以改进客户端的算法。因为通过Hash算法未必能够将压力分摊均匀,就好比一些处理需要耗时比较久一些处理耗时比较少,系统对于key的映射不均衡等等问题,不过在Dynamo中描述的并不很明确,其中的算法还是要根据实际情况来做的。

How I learned to say ‘No’ to SQL

consistent-hashing算法
High Performance Scalable Data Stores

I Can’t Wait for NoSQL to Die

NoSQL DZone Poll Results

转载:公司治理

原文地址:http://hutuworm.blogspot.com/2010/04/blog-post.html

1. 有目标,无规划,有组织,无纪律,讲战略,不讲战术,这就是完全没有公司治理概念的公司。
2. 讨论任何问题都要从 1+1=2? 开始,讨论者不具备任何基础的背景知识,这就是无效率的会议为何如此众多的原因。
3. 从补丁式开发进化到补丁式管理,任何问题都寄望于通过一套新的附加流程来小范围解决。头痛医头,脚痛医脚,治标不治本,却忽视了新增的东西也有成本,也会产生新的问题、新的风险。整体效率永远没有人关心。
4. 管理口号化,流于形式,却不去追究真正的问题根源。主次不分,想到一出是一出,这是一场无序的灾难。
5. 提高效率、控制成本的关键在于标准化,盲目满足个性化需求的结果就是失控。

参考文献
Kevin Kelly, Out of Control http://www.kk.org/outofcontrol/contents.php

Daniel-Journey Weekly Dose-2010/4/4

Java

ThreadLocal是什么

深入探讨在集群环境中使用 EhCache 缓存系统

WEB

加速Javascript:DOM操作优化

Linux

Linux内存模型

文件默认权限:umask

查看方式有两种,一种是直接输入umask,可以看到数字类型的权限设置分数,一种是加入 -S(Symbolic)参数,就会以符号类型的方式显示权限。

在默认权限的属性上,目录与文件是不一样的。由于我们不希望文件具有可执行的权力,默认情况中,文件是没有可执行(x)权限的。因此:
• 若用户建立为”文件”则默认“没有可执行(x)项目”,即只有rw这两个项目,也就是最大为666分,默认属性如下:
-rw-rw-rw-
• 若用户建立为”目录”,则由于x与是否可以进入此目录有关,因此默认为所有权限均开放,即为777分,默认属性如下:

umask指定的是“该默认值需要减掉的权限”。因为r、w、x分别是4、2、1,所以。也就是说,当要去掉能写的权限,就是输入2,而如果要去掉能读的权限,也就是4,那么要去掉读与写的权限,也就是6,

Architecture & Design

IOU 设计模式介绍及应用

IOU 思想是人们在处理日常债务关系时行之有效的一种方法,即:

  • 债务人通过可靠的第三方保管账户,向债权人发放 IOU 债务凭证;
  • 债务人通过向第三方保管账户提交结果以终止 IOU 债务;
  • 债权人凭此 IOU 债务凭证通过第三方保管账户履行债权并进行结果赎回。

债务人和债权人之间的债务关系,通过可靠的第三方保管账户,实现了在时间和空间上最大程度的分离和解耦。

IOU 设计模式是 IOU 思想在软件设计领域的应用,最早由 Allan Vermeulen 于 1996 年首次提出。在软件设计领域,债务关系发生在方法调用者和方法体之间,债务对象就是方法的返回结果。普通方法的调用模型是方法体同步执行然后返回结果,调用者必须等待结果返回后才能继续执行。在 IOU 设计模式下,方法体将立即返回一个 IOU 对象,并且承诺 IOU 对象最终一定会被终止,调用者在 IOU 对象被终止后可进行结果的赎回。在此期间,调用者无需等待就能够继续进行其它有价值的事务,从而达到了提高程序整体的并发性和异步性的目的。

IOU 设计模式完全不依赖于任何一种异步机制,IOU 对象的提供者可以选择任意有效的方式来执行服务并最终终止 IOU 对象,比如启用独立的线程/进程执行、驱动异步事件产生、通过远程方法调用或是等待用户终端输入等等。这是 IOU 模式具备普遍适用性的一个重要因素。

Q1技术回顾

SOA

Services vs. Applications

Services Applications
Perform a single or a few specialized operations. Perform a wide range of operations, and may even expose some of these operations as services.
Most often accessed by other programs. Often (but not always) accessed by humans.
Often (but not always) targets part of a larger problem domain. Often (but not always) targets a whole problem domain.