Write Code As If You Had to Support It for the Rest of Your Life

Yuriy Zubarev

YOU COULD ASK 97 PEOPLE what every programmer should know and do, and you might get 97 distinct answers. This could be both overwhelming and intimidating at the same time. All advice is good, all principles are sound, and all stories are compelling, but where do you start? More important, once you have started, how do you keep up with all the best practices you’ve learned, and how do you make them an integral part of your programming practice?

I think the answer lies in your frame of mind or, more plainly, in your atti- tude. If you don’t care about your fellow developers, testers, managers, sales and marketing people, and end users, then you will not be driven to employ test-driven development or write clear comments in your code, for example. I think there is a simple way to adjust your attitude and always be driven to deliver the best quality products:

Write code as if you had to support it for the rest of your life.

That’s it. If you accept this notion, many wonderful things will happen. If you were to accept that any of your previous or current employers had the right to call you in the middle of the night, asking you to explain the choices you made while writing the fooBar method, you would gradually improve toward becoming an expert programmer. You would naturally want to come up with better variable and method names. You would stay away from blocks of code comprising hundreds of lines. You would seek, learn, and use design patterns. You would write comments, test your code, and refactor continually. Support- ing all the code you’d ever written for the rest of your life should also be a scalable endeavor. You would therefore have no choice but to become better, smarter, and more efficient.



If you reflect on it, the code you wrote many years ago still influences your career, whether you like it or not. You leave a trail of your knowledge, attitude, tenacity, professionalism, level of commitment, and degree of enjoyment with every method, class, and module you design and write. People will form opin- ions about you based on the code that they see. If those opinions are constantly negative, you will get less from your career than you hoped. Take care of your career, of your clients, and of your users with every line of code—write code as if you had to support it for the rest of your life.

最新文章

  1. BIRCH聚类算法原理
  2. ubuntu安装node.js+express+mongodb
  3. robotium重签名使用解决办法
  4. 【转载】SQL Server 2008 r2 中 SQL语句中单引号转义
  5. 【PHP面向对象(OOP)编程入门教程】3.什么是面向对象编程呢?
  6. Java hour5
  7. Codeforces Round #149 (Div. 2)
  8. 在PowerDesigner中设计概念模型
  9. C#系列之String和StringBuilder
  10. KEIL C51中的_at_关键字
  11. PCB外形加工
  12. C++之static_cast, dynamic_cast, const_cast
  13. 条码知识之十:EAN-128条码(下)
  14. 经常使用git命令集
  15. linux设置静态IP和DNS以及改网卡名
  16. java web 获取客户端操作系统信息
  17. 常用VIM插件配置
  18. 使用 jenkins 搭建CI/CD流水线 (MAC)
  19. (转)python高级FTP
  20. ptime概述

热门文章

  1. mac自己定义tree命令
  2. 细说 iOS 消息推送
  3. 动态库dll使用module.def文件导出函数(像静态库一样使用)
  4. Zabbix监控告警
  5. activity 接回返回值
  6. 数组&对象
  7. Vue 打包后报错 Uncaught TypeError: Cannot redefine property: $router
  8. Direct2D 图形计算
  9. Nodejs源代码分析之Path
  10. ubuntu-系统卡慢解决(转载)