Change - Why we need coding standards

I have the idea of coding standards when I have to review my team’s code.  I found it's painful to review others' code, for there was no official coding standards that time.  Somebody may say, though we don't have a coding standard, most parts are the same.  How most it is?  We don't know, and they didn't need to do code review that time.

After I worked for an outsourcing company, I found strict coding standards were surprisingly effective and useful.  Nowadays, I believe every programmer is sure that coding standards are useful. Don't say that before I tell you what the coding standards is.  Give you a simple demo:

How about this time?

At our company, we could look at any piece of code, anywhere in msstash, and we could read it. Could you easy to look at a piece of unfamiliar code and understand it?  You will found that it’s awful to read other teams’ code, even other people’s code in your team.  But why, do you think of that?

Do you have the standardization of style - indents, names, file structures, and comment conventions, for yourself, your team, and your company?

After I read MarkCC’s article about coding standards, I think it covered most of the reason why people don’t like it.

There's a suite of common objections to this, codify and simplify as below.

 

It wastes time!

I'm a good coder, and I don't want to waste time on stupidity.  I'm good enough that when I write code, it's clear and easy to understand.  Why should I waste my time on some stupid standard?

I'm an artist!

This is phrased facetiously, but it does reflect a common complaint.  We programmers have a lot of pride in our personal style.  The code that I write really does reflect something about me and how my mind works.  It's a reflection of my skill and my creativity.  If I'm forced into some stupid standard, it seems like it's stifling my creativity.

One size fits all actually fits none!

If you have a coding standard that wasn't designed specifically for your project, then it's probably non-optimal for your project.  That's fine.  Again, it's just syntax: non-optimal doesn't mean bad.

I'm too good for that!

This is actually the most common objection.  It's sort-of a combination of the others, but it gets at an underlying attitude in a direct way.  This is the belief on the part of the complainer that they're a better programmer than whoever wrote the standard, and lowering themselves to following the standard written by the inferior author will reduce the quality of the code.

When you're coding against a standard, there are inevitably going to be places where you disagree with the standard.  There will be places where your personal style is better than the standard. But that doesn't matter.  As long as the standard isn't totally ridiculous, the comprehension benefits are significant enough to more than compensate for that.

But what if the coding standard is totally ridiculous?

Well, then, it's rough to be you: you're screwed.  But that's not really because of the ridiculous coding standard.  It's because you're working for idiots.  But it won’t happen in our company.

Many questions we may meet:

  1. Our team has coding standards, it’s enough.

Coding standards could be personal, team, department, company, industry.  The higher the better and the best is company level.  It makes easy to read code crossing teams and share.

  1. I know what the code meaning.

Code is not for you.  At least it is for your team.

In an agile team, we should conduct code review, pair programming, etc.  All these must base on coding standards.  I guess no one wants to review the code if it’s not your style, much more maintain it.  Buy why it’s your style, only when your style is equal to the company style.

Change - Why we need coding standards的更多相关文章

  1. C# Coding Conventions, Coding Standards & Best Practices

    C# Coding Conventions, Coding Standards & Best Practices Cui, Chikun Overview Introduction This ...

  2. linux c coding style

    Linux kernel coding style This is a short document describing the preferred coding style for the lin ...

  3. [中英对照]Linux kernel coding style | Linux内核编码风格

    Linux kernel coding style | Linux内核编码风格 This is a short document describing the preferred coding sty ...

  4. coding规约的网站, 从sonar中链接过去

    一个coding规约的网站, 从sonar中链接过去的. 挺好. https://wiki.sei.cmu.edu/confluence/display/seccode/SEI+CERT+Coding ...

  5. 16/7/8_PHP-书写规范 PHP Coding Standard

    变量命名规范这里感觉 打算采用 匈牙利命名法+驼峰法命名,因为 PHP是弱类型语言,很多时间因为忽略了变量类型而导致犯一些低级错误.所以在前面加上类型名有助于更好的理解代码. 下载是转载 PHP书写规 ...

  6. a* products

    Experience of black-box testing on set-top-boxes/IP-connected devices, games consoles and tablets ht ...

  7. php.ini

    [PHP];;;;;;;;;;;;;;;;;;;; About php.ini   ;;;;;;;;;;;;;;;;;;;;; PHP's initialization file, generally ...

  8. PHP配置详解

    [PHP] ;;;;;;;;;;;;;;;;;;; ; About php.ini ; ;;;;;;;;;;;;;;;;;;; ; This file controls many aspects of ...

  9. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

随机推荐

  1. cannot be resolved to a type (Java)

    最近经常遇到cannot be resolved to a type (Java)报错,以下为在网上找到的解决方案: 1.先看看有没有引用相关jar包2.检查jar是否引用了多个相同的,或者多个jar ...

  2. 16、xtrabackup 增量备份及恢复

    备份命令如下 备份命令如下 全量备份 #  innobackupex -p123123 /backup # ls /backup 2017-04-08_13-36-11 增量备份或差量备份 # inn ...

  3. bzoj4241: 历史研究(回滚莫队)

    传送门 这是一个叫做回滚莫队的神奇玩意儿 是询问,而且不强制在线,就决定是你了莫队 如果是每次插入一个数是不是很简单? 然而悲剧的是我们莫队的时候不仅要插入数字还要删除数字 那么把它变成只插入不就行了 ...

  4. JPush Android 推送如何区分开发、生产环境

    我们 Android 开发者在使用极光推送时可能会发现,在通过官方控制台进行推送时.只有 iOS 区分了开发和生产环境,而 Android 则没有.但实际开发中又确实经常需要针对开发和生产环境分别来推 ...

  5. POJ1475 Pushing Boxes(双搜索)

    POJ1475 Pushing Boxes  推箱子,#表示墙,B表示箱子的起点,T表示箱子的目标位置,S表示人的起点 本题没有 Special Judge,多解时,先最小化箱子被推动的次数,再最小化 ...

  6. c语言-猜生日算法

    #include<stdio.h>int main(){ int a1[6]={1,3,5,7,9,11}; int a2[6]={2,3,6,7,10,11}; int a3[6]={4 ...

  7. 题目1016:火星A+B(字符串拆分)

    问题来源 http://ac.jobdu.com/problem.php?pid=1016 问题描述 每次输入两个数,不同数位之间用逗号隔开,其中,第n位的进制就是第n个素数,即个位数是2进制的,十位 ...

  8. WINDOWS SERVER 2012标准版密钥

    Windows Server 2012 R2 安装密钥(只适用安装,不支持激活) 标准版 = NB4WH-BBBYV-3MPPC-9RCMV-46XCB MMPXK-NBJDQ-JPM34-WX3FM ...

  9. RPC与本地调用的区别

    RPC远程调用:一般可以跨平台通讯,采用http协议.因为http协议底层使用socket技术,只要你的语言支持socket技术,就可以相互进行通讯.比如:java语言开发的接口,http协议,然后让 ...

  10. 初识express

    初识Express 1.简介: express是基于Nodejs平台的快速,开放,极简的web开发框架 2.安装 npm install express --save 3.Hello world: c ...