关闭

六月定律

1060人阅读 评论(0) 收藏 举报
分类:

本文来自: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.

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:808524次
    • 积分:6114
    • 等级:
    • 排名:第4098名
    • 原创:116篇
    • 转载:21篇
    • 译文:0篇
    • 评论:130条
    最新评论