六月定律

本文来自: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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值