| 伟's profile晴朗下午PhotosBlogLists | Help |
晴朗下午May 08 Healthy computingIntroduction
Any type of work can lead to injuries and other health issues. Computer work is no exception to this rule. When programming, we often have to spend many hours sitting in the same position and staring in one direction. Even if we cannot control the amount of time that we spend at the computer, we can at least control how we spend it. We must remember that neglecting a healthy computer environment increases the risk of immediate injuries and can lead to severe health problems in the future. These issues are no joke and should be treated seriously. In this article I would like to describe how to avoid and overcome injuries related to computer work. This involves having proper set up for your chair, keyboard, mouse and monitor, as well as, having correct sitting posture, document positioning and use of input devices. Finally, I will touch on some simple exercises that will keep you healthy during long working hours. Setting up the chair
First lets have a look at chairs as they are the single most important component to a healthy environment. There is no such thing as a perfect chair and you should try a variety of chairs to find the one that suits you best. Chairs that have wheels are generally a good idea, especially if you are working at multiple desks and need to move around the room. Be careful though; because some floors are slippery and make you unintentionally move backwards as you type. If you are using a non-adjustable chair and it is too high then consider using a footrest. The main idea is to feel comfortable while sitting in your chair. This means that your back should be well supported and the actual seat does not apply too much pressure to the back of your knees. Adjust the chair height until your feet are comfortably placed on the ground and your knees are nicely relaxed. Next adjust the reclining angle. Experts recommend keeping the chair slightly reclined, as this helps relieve tension from your lower back. Also if you can, adjust the reclining tension so that the chair provides consistent support as you move back and forth. Sitting posture
Your sitting posture is also important. It is a good idea to change your posture every now and then. By doing so you will improve circulation and reduce muscle fatigue. Your back should be comfortably reclined - it should not be erect or leaning forward. Your head should be well balanced - do not tilt it back or too far forward as this will strain your neck. Your arms should be relatively close to the body - not out to the side or too much to the front. Your wrists should be roughly level with your forearms. If your chair has armrests then make sure that they do not interfere with your arm movements. Document positioning
Often we have to work from printed documents while using the computer. Improper positioning of documents can lead to neck and shoulder pain. Try to keep your body straight and avoid twisting it at awkward angles. It helps to have a large desk so that both monitor and documents can be in direct view. If your desk is too small to fit your documents then consider using a monitor mounted document holder. On a personal note, I strongly recommend learning how to touch-type. Not only does it save you time, but also prevents you from having to constantly turn your neck while typing. Choosing the right keyboard
When it comes to buying a new keyboard there is no shortage of choice. The most commonly used type of keyboard is the "101-key traditional" keyboard. Generally these are well suited for everyday use and there is no need to change them unless you have special requirements. If you have a broad chest then perhaps you should try a split keyboard. Split-design keyboards divide the letter keys into two halves. By doing so, they aim to achieve a more natural position for your wrists and forearms. Contoured keyboards arrange the keys in a way that approaches the natural position of your fingers. This reduces the distance that your fingers have to travel between keys, thus minimizing the risk of strain. Finally, there are keyboards that use a different layout altogether. For example, chording keyboards use fewer keys and are operated by using combinations of keys instead of individual keystrokes. Dvorak keyboards position the most commonly used letters directly under the user's strongest fingers. Although these keyboards have their own advantages, they take considerable time to master.
Setting up the keyboard
Now lets examine some of the ways in which you can adjust your keyboard. Ideally you should have a keyboard tray, as this allows you to make both horizontal and vertical adjustments. Position the keyboard so that it is about 4 inches above your lap level. Always un-extend the "legs" that are attached to the front of your keyboard. If you can, tilt the keyboard slightly forward, as this will keep your wrists in a relaxed neutral position. Position your keyboard so that the middle of the letter keys is centered with respect to your body. Using the keyboard
When typing it is important to follow a few simple guidelines. Try to use a light touch, because striking the keys too hard can strain the tendons from your fingers. Do not bend your wrists up and down too much as this can cause pain and lead to injuries. Keep your elbows at angles equal or greater than 90 degrees - this avoids nerve compressions that lead to sore wrists and arms. Do not use wrist rests or armrests while typing - only use them when resting. Avoid raising you shoulders to meet the keyboard, instead you should lower the keyboard or adjust your chair height. Setting up the mouse
The mouse can be set up in a similar manner to the keyboard. If the mouse is too far from the keyboard then your shoulders will tire from supporting your outstretched arm. So place your mouse within easy reach, close to the keyboard. Use your operating system to adjust the mouse's speed and response time. As mice come in different shapes and sizes it is important to find one that fits comfortably in your hand. Using the mouse
When using the mouse try to avoid making "flicking" movements with your wrist as this can lead to wrist and finger pain. Instead, move the mouse with your forearm. A scroll wheel is an absolute must when editing those long documents and pieces of code. Avoid having your fingers "hover" above the buttons - give them a rest by letting them lie gently on the buttons. Also avoid tilting and angling your wrists - keep them in a neutral position. Just like with keyboards, there is no need to use excessive force when clicking mouse buttons. Setting up the monitor
It is vital to position your monitor correctly, because failing to do so can lead to neck pain, shoulder pain and even eyestrain. The best position for the monitor is in the center of your workspace. This position guarantees that you don't have to experience any uncomfortable twisting and awkward posture. Just like with televisions, it is not advisory to sit too close to your monitor. You should sit about an arm's length away and even further for monitors that are larger than 19 inches. Position your monitor so that the top of the viewing area is about 2-3 inches above your eye level. Reducing glare
Window light can cause many viewing problems associated with monitor use. For example, if your monitor is positioned next to a window then you will have competing brightness levels between the window and the monitor. This can be very uncomfortable and often causes headaches and fatigue. On the other hand, a window situated behind you will produce glare. One solution is to keep windows mostly shut and use overhead lighting. Another solution is to attach an anti-glare screen to your monitor. However the best solution is to use an LCD (liquid crystal display) monitor. These monitors are ideal, because they emit minimal glare and save desk space at the same time. Exercises Now for some exercises that you can do between work to relieve tension and muscle fatigue: Stand up and stretch your arms over your head. Give your eyes a rest by looking into the distance or closing them for a few seconds. Turn your neck slowly to the left for 5 seconds and then to the right for 5 seconds. Repeat several times. Relax your arms at your side and rotate your shoulders in a circular motion. Clasp your hands behind your back and slowly arch your back, bending your head backwards. Hold for up to 5 seconds. Place your hands palm-to-palm and slowly rotate them away from you until you feel a mild stretch. Clench both fists and hold for 5 seconds. Now spread your fingers as far as you can and hold for another 5 seconds. Repeat several times. March 29 什么是专家? Specialization is knowing more and more about less and less until you know everything about nothing. March 22 对我未来的简单规划
做8~10年程序员。前3年在Sigrity,之后选择一个注重技术的公司,比如Google。让我的工作充满挑战。让我多多赚些钱。 我是一个passionate,自信,骄傲的程序员。但是现代文明的所有东西常常令我惊讶,有时坐着地铁,看着各种塑料制品。我就感觉这个世界优秀的人太 多了。至于我,我必须让我的这一优势为世界带来一些有价值的东西。然后,也就是约8年后,我就要向开始学习我的新专业了。那就是声学。不要废话说这样子的 职业的发展不是连续的,我可以读一个声学方向的学位,然后我就会学会所有转型需要的知识,非常容易。 人的职业生涯是短暂的,人的一生虽然短暂,也要比人的职业生涯多约30年。(20年长大,10年养老). 因此10年的时光在职业生涯中不是短暂的。用这么长的时间来满足我对软件业的热情,补偿我大学时的热情,迷茫和苦恼,可以了。 因为我在十年后不是做程序员了,我不是和我的Team member一起共事,那时候我跟着一个优秀的声学专家,在各个音乐厅里做各种测量。为设计有更好声学性能的建筑而提供建议。因此提高我的综合素质是非常必要的。 记得金强告诉我Daily summary and plan怎么写时说,plan可以写的简单点。说的没错。 “For a better future we forget good now." "Tomorrow is unpredictable, yesterday is past, today is a gift, that's why today is called present". 所以,规划未来应该被投入较少精力,规划现在应该被投入更多精力,而度过现在,则应该被投入最多精力。 如何充实自己的业余时间。 1. 多锻炼身体, Balance phisical and mental. 2. 多拜访朋友。 3. 写博客,以便多认识些同好。 4. 给几位好朋友写email. 5. 学习哄人开心。 6. 爱情尚遥不可及,干脆铁定注意。让自己心静3年。既然围城到处都是,何必继续验证?单身的生活也会有乐趣-可能会更多。停止任何瞎折腾。 7. 任由自己的兴趣蔓延。 从今天起,面朝大海,心态乐观。想想前两天牙龈发炎的日子。那才是真正的痛苦。这种日子都能过,还有什么不美好?!人生苦短,既然人会希望长生不老,又何必让自己有日子过不去的无聊? March 09 春天来了,好多期望! 接连下雨多天,今天天气一下子好晴朗!
柳树上已经长了许多新芽,嫩嫩的,绿绿的。
所有心里的期望在春光里重新结芽青绿了!
所有最美好的记忆,所有梦寐中的期盼!
这个全新的季节!
我亲爱的看到这篇日志的朋友,我愿所有美好的东西,如春天的到来一般,不可抗拒的,自然而然的进入你的生活!
刘伟的每一刻都是崭新的! February 22 接连做了两个噩梦大概最近睡眠状况变差了,虽然睡眠时间更长了 - 以前的时候躺在床上还要看看东方电影频道有什么好看的片子,现在躺在床上,一打开电视眼睛就睁不开。整个人慵懒异常,只想闭着眼睛。
昨 天晚上做的两个噩梦太可怕了,要不是早就是一个唯物主义者,我估计都要精神异常了。在第一个噩梦中,我还是躺在床上,看到有两只很毒的虫子在我的鞋子里面 跑来跑去,我人好像懒懒的,随手拿起一瓶不知道什么东西喷了喷,虫子跑到墙上去了。于是我又得过且过的睡下了。然后便是稀里糊涂 - 梦都是不连贯,杂乱无章的。突然间,鞋子已经穿在我的脚上了!
鞋子穿在我的脚上!
我意识到事情不妙,赶紧脱下鞋,天啦!只见我第脚底一串串疙瘩,有大有小,一直延伸到了大腿那里。其中的有些肿块变得非常大!
于是在一阵恶心和悚然中,我醒了过来。
这 个恐怖的梦让我想起了中学的免疫知识。人的身体是有区别“自我”和“非我”的能力的。当免疫系统察觉到外界的入侵时,会动员一些英勇的细胞去消灭异类。因 此发炎时白细胞的数量会大大增加,红肿的地方也是白细胞聚集的结果。在我的梦中那些肿块那么大,说明这显然是一场惨烈的战斗。
- 人的免疫系统是非常重要的... 是我们的祖先用自然选择中大量同类的牺牲换来的。我们的祖先都是基因上的佼佼者。
迷糊中我摸了摸自己的腿,发现那里的皮肤都是平的,“还好只是个梦啊” 我想,于是我又睡着了。但想不到又有一个噩梦等着我。这个该死的噩梦给人一种日有所思,也有所梦的感觉。
我梦见自己不知道怎么样,总之我刚刚有一个某某学科的更高的学位的样子。然后我跑过去面试,但是,当我到我面试的地方时,却发现这个地方和生化危机中某个破败的仓库一样。我穿过阴冷的地下室,被带到了一个像废品堆积室般的地方,然后好像胡乱的在说着什么。
接 着蒙太奇般的,我突然得到了兰州的“海默石油流量计公司”的消息,说我被解雇了。其实我早已经不在那里上班了。我在那里培训了一个月的英语并且效果不错, 进步很大。有个叫Mejdi的人在兰州工专上课,同时跑到各个公司做商务英语培训。还有个叫刘一川的老师会很可爱的示范 "our" 怎么样读 - 但问题是我在那个梦里,听到我被海默解雇的时候,感觉很不好。
这就是我的第二个噩梦。这是一个残酷的噩梦,残酷的原因是他太真实了。裁员,压力,疲惫,迷茫。所有都是现实中的残酷。这些残酷不像是南京大屠杀,不像是人肉叉烧包,你看了后会矫情的叹息几声,但心里清楚其实他们离自己很遥远,然后去打几局麻将,吹一吹牛。
也 许我还没有拥有一个真正成熟的心态,我一直在企图去多了解一些行业,了解不同人的历史的生活工作状态,发现最适合自己的路。我告诉自己,迷茫是一种这个阶 段必然的状态,或许在我工作后很长时间,我的目标只是给自己一个方向。我是精力充沛的,是聪明好动的,是不吝惜自己的努力的。但混乱,毫无控制的热情只有 在运气极好的情况下才会给一个人期望的生活。要明确方向,就得学习社会。
学习社会不是一个可以从Google搜到答案的题目,不是通过读一本《Find out your career path in 21 days》就可以明白的道理。所以我给发现自己的方向以充足的耐心,话虽如此,但似乎我还是有那么点担忧,否则,怎么会做这样的梦呢?
当我想起梦中那破败的仓库的时候,我就想到了当年参观学校号称“亚洲最大的消声室”时的感受,太破了。但是听说有人用这么破破烂烂的东西赚了无数米。真的有那么多吗?
思而不学则罔! February 13 脚本语言更快还是C++更快?安静!!我知道你是一个很优秀的软件工程师,我知道你认为这种讨论毫无意义。但请不要急着扔鄙视的砖头,请先听我把话说我。耐心点!我要告诉你的是新东西! 话还得从我之前对Tcl的解释器做的一点小小改动说起。当时公司需要在产品中嵌入Tcl的解释引擎,但在工程中加入了Tcl的代码后,运行结束时却发现了大量的内存泄漏。因此习惯打杂的我被叫过去解决这个问题。仔细的阅读了Tcl内存管理的算法后,我发现Tcl的的内存使用方式的确是相当高效的。 Tcl内部有一个Bucket列表,每个Bucket包含一个可用内存块的链表,链表中所有内存块的大小是相同的。内存的申请与回收主要通过这种缓存完成。 我们以一次内存申请过程为例,假设要申请的内存大小为50,那么一次申请的过程如下: 1. 首先查找大小为64的Bucket中是否有可用内存块,如果有,则直接将该块取出返回。 2. 否则,从最大Bucket开始查找一块可用内存,将其切分为大小64的小块,这样大小为64的Bucket又有可用内存块了。 3. 如果在进行第二部的时候找不到更大的内存块,则向OS申请。申请的大小为最大Bucket中内存块的大小。 至于内存回收时,则直接将其放回大小与其对应的Bucket中。 这里大家也明白为什么我们在嵌入Tcl的时候会发现内存泄漏,因为Tcl对内存本来就是只吞不吐的,所有使用完毕的内存都被缓存了下来 – Tcl依赖Windows来做内存回收的。 不谈我们是怎么解决这个问题的,我想说的是,这种内存管理策略是相当有效的。 首先,由于所有向操作系统申请的内存都是固定大小的,因此可以大大减少内存碎片。 其次,多级的内存管理方式大大减少了堆查找所消耗的时间。 再次,对于常见的应用程序,开发人员所申请的内存的大小常常落在一定范围。因此当程序运行一段时间后,反复的内存申请,释放将会是不停的把一块内存放入,取出某个Bucket,如果内存管理是交给OS的,想想性能会差多少! 最后,在多线程的Tcl中,每个线程都会拥有自己的Cache,这可以大大降低malloc是lock全局堆所浪费的大把时间。 现在回到文章开头的观点,为什么有时候脚本语言会比C++快?让我们来这样想象一下,我们现在要开发一款坦克大战游戏(抱歉一时间想不出更好的例子了),里面会不断的创建子弹对象,敌人的坦克对象,各种效果对象,又不断的销毁,因此内存申请与回收的效率对运行速度非常重要。使用C++的程序员将直接使用操作系统提供的内存管理功能,而使用Tcl的程序员,虽然脑子里面思考的东西和使用C++的程序员差不多,却已经不知不觉中使用了经过更好优化打内存管理策略。因此使用Tcl写出来的程序很可能会跑得更快。 当然了,内存的管理只是Tcl所做的优化中的一种,因为我没有完全读过Tcl的代码,所以很难说Tcl还做了什么能大幅提高效率的优化。但我相信肯定还有不少我所未知的优化。 当然,你可以说Tcl也是用C写的。但问题是你自己用C写代码的时候会考虑这么多吗?你不会啊! 你还可以说用C也可以写出很robust的代码,但通常你嫌麻烦啊,或者也写的很累啊! 所以我认为: 1. 不必用C++写的代码,尽量不用C++,或者尽量少用。 2. 多学点各个层次的计算技巧,要比死抱着C++重要的多。 3. 多了解一下编译器如何优化,也要比在C++里面硬嵌汇编更能提高性能。(同样的道理,汇编不见得比C++快,有时候我看反汇编的代码时,发现编译器的优化能力令我发指!) February 11 如何读代码1 - 驳斥两条常见误区首先我必须有力的反击在软件开发中充满迷惑性的两点误区,据我所知者两点误区已经深深毒害了软件开发人员多年,大大的降低了代码质量。他们是:
1. 我们的代码应该有很多文档。 2. 我们的代码似乎很烂。
首先来看看误区1:
在软件开发中,新加入一个项目的程序员常常会有这样的抱怨: “我们的代码没有文档”。这种抱怨甚至会得到项目中已经颇有经验的程序员的附和。但其实这种抱怨是带有不合理要求的,不应该支持的,是可以驳回的。
首先,这世界上90+的软件是没有(或缺乏)文档的,千万不要以为在大公司会有很“理想”的写一大堆文档然后才开始写代码的“正规流程”。如果不相信,可以问问你在大公司,比如Microsoft, IBM等工作的朋友,看看我们耳熟能详的那些软件到底有多少文档。似乎只有外包公司比较重视文档,然而敏捷开发的风行也使开发者对书写笨重的文档难以保持耐心。文档与代码的不同步也使许多文档变得失去意义。
其次,让我们来看看文档对于开发者的意义。也许新加入的项目组成员会想,在理想的情况下,只要让我先看看文档,一点代码都不用看。等我通读完文档后,我打开代码就懂得全部的代码啦!然而这真的很幼稚。
好吧,也许你理由还是很充分,你认为磨刀不误砍柴工,你认为…. , 总之你认为就是应该有文档嘛!但是我们得面对现实的对不对,现实是,你所拥有的只是一堆代码,放在一个Visual Studio的Solution文件里面,你无法使用心爱的Adobe Reader, Microsoft PowerPoint and Visio,你只能使用对着Visual Studio,阅读一行行代码,所以,你所能考虑的只应该是如何多快好省的搞懂这些代码。
当然,我不是说你应该不写文档。
误区二:
好吧,无论有没有文档,有一件事情是肯定的,你现在对代码有了一些了解。是时候发表点自己的评价了,于是你说:
“我们的代码烂到家了!”
你的评价是有道理的,因为你的评价基于你对软件开发的真知灼见。你举出了无可动摇的事实,你说:
“这个地方应该用State模式,而我们则使用了大量的 if, else, switch。这个函数纯粹就是一个万能函数,并且与另一个函数严重耦合,更糟的是函数名也挂羊头卖狗肉。这个地方应该用二分查找,这里则应该用动态规划提高效率…”总之:
“这代码真应该从一开始就让我写!”
好主意!如果一开始就让你写,或许你会理解所有代码的来龙去脉,你会认为代码本来就应该是这个样子。你会认识到我们为得到这些混乱的代码,所付出的巨大努力:一个个优秀的程序员,一个个目光犀利的QA,以及大量花数年时间使用我们软件的客户,如辛勤哺育孩子一般,让我们的软件逐渐成长起来,而有人却认为他很烂?!
现在让我们看看我们的代码,看看这个5000行以上的函数,里面署有50位程序员的大名。而他的功能仅仅是显示一个窗口,随着岁月的积累,他开始变得庞大。但是不像中年发福的人,这个函数的增长,是在积累有用的东西,那就是:Bug fix。有人发现在没有安装Internet Explorer时窗口不能正确的现实,有人为内存不足时正确的现实窗口做了点特殊处理,为了使某个将数据存储与局域网服务器的客户能看到给窗口,我们还得加点代码;至于丑陋的LoadLibrary的调用,则是为了支持Windows 98以及Linux用户。
所有这些bug的发现都是在我们的软件被大量使用 - 测试之后发现的,定位这些bug花了我们大量的精力,时间。在一个个Bugfix 中,我们的软件从一个婴儿 – 单纯,简洁,变得越来越成熟,稳定,越来越善于处理来自客户的需求。然而,随着一个个Bug被修掉,我们的代码会逐渐零乱,代码中或许会混杂着各种各样的风格,或许会有重复的API调用,或许有些地方必须要提高性能了,甚至或许会有自相矛盾的地方。但是你应该感觉得到与这微不足道的缺陷相比,他所能提供的强大的功能,他所具有的巨大的容错性,才是我们代码真正的本色!
至于那些毛病,我们有你,优秀的开发人员。对于软件进化已成为软件开发主流的当代,代码重构是一个程序员最需要提高的能力。
况且,从态度来说,一个喜欢自己工作与之上的code base的程序员,会有更积极的态度,因而也更能改进现有的代码。 |
|
|||||
|
|