六月定律

来源:互联网 发布:鲁振顺 知乎 编辑:程序博客网 时间:2024/04/27 08:27

本文来自:http://blog.marcomonteiro.net/post/the-six-months-rule

上周,我被迫对一个很老的项目做一些修改。麻烦是,当开始着手时,我真的记不清这个项目究竟有多老了。

这实际上是我使用Codeigniter实现的第一个MVC项目。打开项目文件后,很多东西都让我头晕。首先,没有版本控制,第二,没有注释。

<img size-full="" wp-image-7490="" lazy="" "="" src="http://static.oschina.net/uploads/img/201311/12081239_RJ3T.png" alt="WTF" width="500" height="453" style="margin: 0px; padding: 0px; border: 0px; max-width: 640px; display: block; ">

读起代码,我的“F*CK/分钟”的值一直冲破屋顶。

项目里面的Model很少。Controller层有大量重复的代码,View层肥大的令人毛骨悚然。我相信View层里的逻辑实际上比Model层和Controller层的加起来都要多。

我该为此感到羞耻吗?

答案是NO。(如果是的话我也不会写这篇博客里。)

为什么不?

因为有个六月定律。六月定律说的是,每个程序员都应该回头看看自己6个月前写的代码,并且应该会唾弃当时写的那些代码。

这就引出了本文的重点:如果你是个程序员,当你看6个月前写的代码时,如果发现跟现在写代码的水平一样,请别写了,你应该学习一些新东西了。

这就是为什么当我看到以前的代码写的奇丑无比时反而很高兴的原因。非常高兴。这说明我进步了。所以,与其为那些丑陋的代码感到羞耻,不如高兴的接受它们,这意味着你在成长。


The six months rule

Oct/01/2012  2 min read  by Marco Monteiro

Last week I had to make some changes into a really old project. The problem was: when I started, I didn’t remember how old the project really was.

This was actually my first MVC project using Codeigniter. When I opened the project there was a couple of things that I started missing. First, no version control. Second, no comments whatsoever.

The first one was corrected. The second one not so much.wtf mesure

Good code vs Bad code

When I started reading my code from that time my rate of “WTF per minute” went to the roof.

My Models were really small. My Controllers had a lot of repetitive code and my Views were morbidly obese. I actually think some of those views have more logic than my Models and Controllers put together.

Should I be ashamed on this?

The answer is no. (Well if I was I wouldn’t be writing this blog post in the first place.)

Why not?

Because of the 6 months rule. The six months rule says that every programer should look at what he was doing 6 months ago and be disgusted about the way he was doing things.

That takes us to the point of this post: if you’re a programmer and you look at your code from 6 Months ago and you’re still doing the exact same thing today. Please Stop whatever you’re doing and go learn something new.

That was why I was really happy to see that awful project being what it is. Awful. So instead of being ashamed of your awful projects, embrace your awfulness, that just means you’re outgrowing yourself.

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 幼儿园孩子不愿意上学怎么办 宝宝不愿意上幼儿园怎么办 孩子不爱上幼儿园怎么办 宝宝不爱上幼儿园怎么办 宝宝不爱去幼儿园怎么办 幼儿园宝宝不爱写字怎么办 小孩贪玩不爱学习怎么办 老师对幼儿不好怎么办 小孩不愿写作业怎么办 小孩怕老师厌学怎么办 幼儿园怕老师厌学怎么办 孩子很怕老师怎么办 孩子怕外教老师怎么办 家长打老师老师怎么办 被学生骂了怎么办 老师经常打孩子怎么办 老师每天打孩子怎么办 小孩不想去幼儿园怎么办 宝宝不想上幼儿园怎么办 小孩不爱学英语怎么办 孩子抵触学英语怎么办 初三了英语不好怎么办 孩子入园焦虑怎么办 家长总是说孩子怎么办 幼师打了小朋友怎么办 幼儿园老师欺负孩子怎么办 被老师冷落怎么办豆瓣 不满老师对孩子怎么办 老师总找茬孩子 怎么办 老师总针对孩子怎么办 老师看你不舒服怎么办 高中孩子不爱学习怎么办 孩子太倔不听话怎么办 老师老说孩子怎么办 孩子13不懂礼貌怎么办 老师不重视你 怎么办 我娃好动不听话怎么办 初三娃不听话该怎么办 小孩爱动不听话怎么办 宝宝吃饭讨神怎么办 孩子速度太慢怎么办