技术债务

by Gabriel Colombo

加布里埃尔·科伦坡(Gabriel Colombo)

如何处理技术债务并节省理智 (How to deal with technical debt and save your sanity)

When was the last time you found yourself working in a file containing 7,000+ lines of code?

您上次发现自己在包含7,000多行代码的文件中工作的时间是什么时候?

I’m doing exactly that at this very moment. Refactoring some functionality from a legacy project along with writing this article.

我正在此刻做这件事。 在撰写本文的同时重构旧项目的某些功能。

Trust me, this sucks.

相信我,这很糟糕。

Unfortunately this is a reality for tons of developers. Projects grow out of control for various reasons. A particular change might not fit the current process or become ineffective in the long run.

不幸的是,对于许多开发人员来说,这是现实。 由于各种原因,项目无法控制。 从长远来看,特定的更改可能不适合当前的流程或无效。

These situations often lead to developers implementing temporary solutions to keep things running. There’s nothing wrong with that.

这些情况通常导致开发人员实施临时解决方案以保持运行。 没有错。

The problem starts to aggravate when these solutions get reused in different functionalities.

当这些解决方案在不同功能中重用时,问题开始恶化。

Re-using a solution without understanding the conditions under which it was developed, and what problem it was to solve, only increases your technical debt.

在不了解解决方案开发条件和解决问题的情况下重复使用解决方案只会增加您的技术负担。

什么是技术债务 (What is technical debt)

The following statement reflects my favorite definition of technical debt:

以下陈述反映了我最喜欢的技术债务定义:

A set of intentful trade-offs made during various development stages of an application.

在应用程序的各个开发阶段进行的一系列有意的权衡。

But what does it mean?

但是这是什么意思?

When creating a new product, important decisions must happen at every stage. Each decision holds a particular weight that affects the development process. Trade-offs must occur.

在创建新产品时,必须在每个阶段做出重要决策。 每个决定都具有影响开发过程的特定权重。 必须进行权衡。

“Do we sacrifice coding standards so we can ship faster?”

“我们会牺牲编码标准,以便我们更快地发货吗?”

“How do we create this feature without over-engineering? It doesn’t need a complete architecture right now, but we’re gonna have to improve it later on.”

“我们如何在不过度设计的情况下创建此功能? 它现在不需要完整的体系结构,但是我们稍后必须对其进行改进。”

As we make more decisions, these trade-offs start to impact the development process. Maintenance problems arise and new features aren’t shipped as fast as they used to be.

随着我们做出更多决策,这些权衡取舍开始影响开发过程。 出现维护问题,并且新功能的发布速度没有以前那么快。

This is the moment where motivation goes down the drain.

这是动机消退的时刻。

I worked on projects based on the following premise:

我基于以下前提从事项目:

“We’re going to switch to a different technology and everything will get discarded. For now, as long as it works, don’t worry too much about coding standards.”

“我们将切换到另一种技术,一切都会被丢弃。 就目前而言,只要可行,就不必担心编码标准。”

If it doesn’t sound too bad for you, let’s look at it from a different angle:

如果听起来对您来说还算不错,让我们从另一个角度来看它:

“We’re all going to die at some point, so while you’re alive, do whatever you want and don’t worry about the consequences.”

“我们都会在某个时候死去,所以当你还活着的时候,做任何你想做的事,不用担心后果 。”

See what I mean?

明白了吗?

Each project should have a set of standards, so that everyone knows how they should do things. These standards should always matter while there’s people working on the project.

每个项目都应该有一套标准,以便每个人都知道应该如何做。 当有人在项目上工作时,这些标准应该总是很重要。

为什么要重构? (Why refactor?)

Back when I was a junior developer at my first job, we were a team of 5, so everyone had to wear many hats at once.

当我刚开始担任初级开发人员时,我们只有5人一组,因此每个人都必须同时戴很多帽子。

I started developing both front and back-end with Laravel. It took time to learn the framework and understand the PSRs (PHP Standards Recommendations), since I’ve never dealt with it before. During this period, some of the code I wrote didn’t meet the standards.

我开始使用Laravel开发前端和后端。 由于我以前从未处理过该框架,因此花了一些时间来学习该框架并了解PSR (PHP标准建议书)。 在此期间,我编写的某些代码不符合标准。

Every Monday I went back and took a look at the code I wrote the week before and everything met the standards. My boss refactored weekly, and sometimes daily if something seemed outrageous.

每个星期一,我都会回去看看前一周编写的代码,所有内容都符合标准。 我的老板每周进行一次重组,如果有些事情看起来令人发指,则有时每天进行一次重组。

This constant refactoring made the project’s structure somewhat unpredictable. Things did break from time to time, especially when working on different branches. Oh well, you know what they say:

这种不断的重构使项目的结构有些不可预测。 事情确实有时会中断,尤其是在不同分支上工作时。 哦,你知道他们说什么:

So one day we were having lunch together and I decided to ask why he refactored our code so often. His answer was something like this:

因此,有一天我们一起吃午饭,我决定问为什么他如此频繁地重构我们的代码。 他的回答是这样的:

“If I don’t refactor, no one will.

“如果我不重构,没人会。

We have a very small team, but eventually it will grow.

我们的团队非常小,但最终会成长。

If you go to our codebase and find it messy and out of standards, you probably won’t take the time to make things right, you’ll simply add another if statement and move on, but if everything is neat and tidy, you’ll feel like doing something wrong by not following the standards”.

如果您进入我们的代码库,发现它凌乱且不符合标准,则可能不会花时间将事情做对,您只需添加另一个if语句并继续进行,但是如果一切都整洁,则您可以如果不遵循标准,就会觉得自己做错了。”

That conversation changed the way I see things, not only as a developer, but as an individual. For that I’m grateful.

对话不仅改变了我作为开发人员的身份,而且改变了我个人的观点。 为此我很感激。

James Q. Wilson and George L. Kelling explored the general concept of his explanation with the Broken Windows Theory.

詹姆斯·Q·威尔逊(James Q. Wilson)和乔治·科林(George L. Kelling)通过“破碎的窗户理论”探索了其解释的一般概念。

Broken windows theory — WikipediaThe broken windows theory is a criminological theory of the norm-setting and signaling effect of urban disorder and…en.wikipedia.org

窗户破损理论—维基百科 窗户破损理论是一种犯罪理论,主要涉及城市混乱和……的规范制定和信号传递作用 。en.wikipedia.org

Their theory presents the following concept:

他们的理论提出了以下概念:

An ordered and clean environment, one that is maintained, sends the signal that the area is monitored and that criminal behavior is not tolerated. Conversely, a disordered environment, one that is not maintained (broken windows, graffiti, excessive litter), sends the signal that the area is not monitored and that criminal behavior has little risk of detection.

一个有序,整洁的环境(可以维持的环境)会发出信号,指示该区域受到监视,并且不容忍犯罪行为。 相反,没有维护的混乱环境(破窗,涂鸦,乱扔垃圾)会发出信号,表明该区域未受到监控,犯罪行为几乎没有被发现的风险。

This makes so much sense when related to programming. If no one cares, low quality code gets shipped and the project gets harder and harder to maintain in the long run.

与编程相关时,这非常有意义。 如果没有人关心,从长远来看,低质量的代码将被交付,并且项目将变得越来越难维护。

Knowing this little backstory, let’s have a look at when to consider refactoring your code.

了解了这些小故事,让我们看看何时考虑重构代码。

何时重构代码库 (When to refactor your codebase)

Constant refactor provides consistency, higher productivity and more control over the codebase.

常量重构可提供一致性,更高的生产率以及对代码库的更多控制。

You should consider refactoring your code if:

在以下情况下,您应该考虑重构代码:

  • The project will continue to run for a long time.该项目将继续运行很长时间。
  • You’re having maintenance problems. (Difficulty on finding and solving problems or making changes to a particular feature).您遇到维护问题。 (难以发现和解决问题或对特定功能进行更改)。
  • Certain functionalities are inconsistent (The same component behaves differently on different pages).某些功能不一致(同一组件在不同页面上的行为不同)。
  • There’s too much code duplication.代码过多。
  • Your functions have way too much business logic.您的功能有太多的业务逻辑。

何时抵制重构的冲动 (When to resist the urge to refactor)

  • The project won’t grow and doesn’t need much maintenance.该项目不会增长,也不需要太多维护。
  • You lack automated testing and isn’t planning on implementing them.您缺乏自动测试,也没有计划实施它们。
  • You wanna migrate to a different technology because it’s trendy.您想迁移到其他技术,因为它很时髦。
  • When refactoring will consume too much time.重构时会消耗太多时间。

结论 (Conclusion)

Technical debt is a huge deal on any project, especially on legacy projects. The earlier we take action to keep it under control, higher the end quality will be.

技术债务对任何项目而言都是一笔巨款,尤其是在遗留项目上。 我们越早采取行动来控制它,最终质量就会越高。

Constant refactoring helps you reduce dependencies and increase maintainability. The codebase becomes easier to test and reason about.

常量重构可帮助您减少依赖性并提高可维护性。 代码库变得更容易测试和推理。

As a starting point, try spotting some of the situations listed above and think about how to improve them. Here’s a great article to help you get started.

首先,尝试找出上面列出的一些情况,并考虑如何改善它们。 这是一篇很棒的文章,可以帮助您入门。

Thanks for reading! I hope you enjoyed this article.

谢谢阅读! 希望您喜欢这篇文章。

If it helps you in any way, please help me spread the word by sharing it :)

如果它以任何方式对您有帮助,请通过分享来帮助我传播:)

Oh! Also, say hello to me on twitter — @gcolombo

哦! 另外,在Twitter上对我问好- @gcolombo

翻译自: https://www.freecodecamp.org/news/tame-your-tech-debt-by-refactoring-more-often-fcc34dd24a33/

技术债务

技术债务_如何处理技术债务并节省理智相关推荐

  1. 公众号后台接管技术支持_哪些技术有望接管开源?

    公众号后台接管技术支持 当您想到开源技术时,您可能会想到那些已经存在多年的技术. 这是有道理的:根据我公司Greythorn在2016年第四季度进行的一项调查, 超过 30%的参与者表示,成熟技术是他 ...

  2. 超越技术分析_超越技术面试

    超越技术分析 by Jaime J. Rios 由Jaime J. Rios 超越技术面试 (Transcending the Technical Interview) "Wow. What ...

  3. 软件技术基础_软件技术(游戏软件开发)专业介绍

    软件技术(游戏软件开发)专业 核心课程 C++程序设计.Java程序设计.C#程序设计.Cocos2d-x游戏开发.Unity3D游戏开发.Android游戏开发.IOS游戏开发.游戏框架设计.游戏服 ...

  4. sql server的密码采用自带什么密码技术存储_【技术分享】浅谈MYSQL 8.0新特性

    于树文 云技术管理处 01 MySQL 8.0中添加的功能 1. 新的系统字典表 整合了存储有关数据库对象信息的事务数据字典,所有的元数据都用InnoDB引擎进行存储. 2. 支持DDL 原子操作 I ...

  5. 机器学习 深度学习技术区别_体育技术机器学习金钱和灵感的圣杯

    机器学习 深度学习技术区别 I claim that anyone with a math background and a love of baseball has at one time give ...

  6. 手机纳米镀膜技术教程_纳米技术将在医疗保健的未来中发挥巨大作用

    手机纳米镀膜技术教程 Nanotechnology has shown great promise in providing timely, precise, and effective health ...

  7. 合肥工业大学机器人技术期末_机器人技术第三次作业(HFUT)

    第三次作业 本人代码水平十分有限,仅供参考,有错误请指出 java源码: package robathomework3; import java.lang.Math; //点类 class point ...

  8. 工业机器人技术试题_工业机器人技术题库及答案

    工 业 机 器 人 技 术 题 库 及 答 案 一.判断题 第一章 1 . 工业机器人由操作机.控制器.伺服驱动系统和检测传感装置构成. √ 2 . 被誉为 "工业机器人之父" 的 ...

  9. 技术债务管理_管理技术债务

    技术债务管理 DevOps Essentials DevOps基础 介绍 (Introduction) Technical debt is one of the most insidious and ...

最新文章

  1. matlab2018a安装后帮助文档打不开解决方法
  2. 想让好友不停地擦手机屏幕?微信头像这样设置就行了!
  3. 七月算法--12月机器学习在线班-第七次课笔记—最大熵
  4. 3_4 IteratorMode 迭代器模式
  5. Bash shell 学习笔记六
  6. php 判断用户是否刷新,ajax php 实现无刷新用户检查是否存在
  7. 极限 lim(x^x-(sinx)^x)/(x²arctanx)
  8. 小银行忍痛放弃资管业务? 转型渠道代销是大势所趋
  9. acer软件保护卡怎么解除_外观精致性能强,配置丰富重量轻、宏碁(Acer)墨舞EX214轻薄笔记本 深度评测...
  10. 两种方式获取revit族文件预览缩略图
  11. java跨域问题Response to preflight request doesn‘t pass access control check: No ‘Access-Control-Allow-Or
  12. Python查询快递订单信息
  13. 属牛的男孩取名:带茂字的男孩名字有哪些
  14. linux at91看门狗驱动设置
  15. 在Unity中制作高质量的光照效果(上)
  16. rgba 转 rgb或者16进制的计算方法
  17. 教职工员工管理MySQL实训_数据库课程设计---教职工管理系统
  18. 9月17日服务器维护,《海岛纪元》9月17日维护公告 「失落之城」正式开服
  19. 10种排序算法比较(直接插入排序、希尔排序、冒泡排序、快速排序、简单选择排序、堆排序、归并排序、基数排序、折半插入排序、2路插入排序)
  20. 玄学题目:洛谷P1027 Car的旅行路线 (写代码就是为了快乐.jpg!

热门文章

  1. media player 控件播放音乐与视频 0130 winform
  2. 数组的降序排序 java
  3. 网页跳转-重定向-102.课时102.【Django视图高级】重定向详解(Av61533158,P102)
  4. django-查询集特性
  5. 转载 实践与分享:Windows 7怎么获取TrustedInstaller权限【图文教程】
  6. 深度解读:GAN模型及其在2016年度的进展
  7. 杂货 - 收藏集 - 掘金
  8. 使用 Xtrabackup 在线对MySQL做主从复制【转】
  9. 一键安装lnmp脚本(包括软件版本)
  10. 学习hashtable,处理“海量”数据