调试代码遗留_陷入遗留代码地狱吗? 这里有一些想法可以帮助您处理情况

news/2024/7/5 9:09:26

调试代码遗留

by Felipe Lopes

通过Felipe Lopes

陷入遗留代码地狱吗? 这里有一些想法可以帮助您处理情况 (Stuck in legacy code hell? Here are some few thoughts to help you manage the situation)

I’m gonna tell you a little story about how I ended up in a legacy code project and how our team managed to get the best from that.

我将向您介绍一个有关我如何结束遗留代码项目以及我们的团队如何从中获得最大收益的小故事。

首先,一点背景 (First, a little bit of context)

I’ve been working for almost a year on a project, that is quite complex, to say the least.

至少可以说,我已经在一个项目上工作了将近一年,这个项目非常复杂。

While I pass the time reading here at Medium about all the awesome things people are doing around the world in software engineering (creating big infrastructures, putting together several cutting-edge systems to respond to thousands of requests per second ), part of my daily life as a software engineer has not been-so-glamorous. Which is to keep an old extension, for an old platform, up and running properly.

当我花时间在Medium上阅读有关人们在软件工程领域正在做的所有令人敬畏的事情(创建大型基础架构,将几个尖端系统组合在一起以每秒​​响应数千个请求)时,这是我日常生活的一部分作为软件工程师并没有那么出色。 这是为旧平台保留旧扩展,并正常运行。

To put it in plain English, I suffer with legacy code.

用通俗易懂的英语来表达,我受制于遗留代码。

First, let me tell you about the bright stack. This extension is meant to run in one of the most important e-commerce platforms, Magento. But Magento released a new version of the platform (2.0), with lots of improvements, implementing most of the good practices, backend developers were hoping to see.

首先,让我告诉您有关明亮堆栈的信息。 此扩展旨在在最重要的电子商务平台之一Magento中运行 。 但是Magento发布了该平台的新版本(2.0),进行了许多改进,实现了大多数优秀实践,后端开发人员希望看到这一点。

For me, it would be great if the extension was made for the latest Magento version, but the extension was developed for the previous version (1.9). An archaic one, lots of times unnecessarily complex, cumbersome and full of intricate xml files. But it does the job. Oh, boy, it does!

对我而言,如果扩展是针对最新的Magento版本进行的,那将是很棒的,但是该扩展是针对先前版本(1.9)开发的。 一个古老的文件,很多时候都不必要地复杂,繁琐并且充满了复杂的xml文件。 但这确实起作用。 哦,男孩,确实如此!

Besides that, the extension, as you may be expecting, is written in PHP, the language everyone loves to hate.

除此之外,正如您所期望的那样,该扩展是用PHP编写的,PHP是每个人都喜欢讨厌的语言。

Although PHP has gained lots of improvements with the latest 7.x version, Magento 1.9 does not support it and I’m forced into working with old PHP versions. Thus, I’m unable to play with all the new stuff. To finish explaining the scenario, there is not a single piece of test. Neither I, nor anyone in the team, was part of the original extension design and development. In the beginning we were kind of lost, most of the time.

尽管PHP在最新的7.x版本中获得了很多改进,但是Magento 1.9不支持它,因此我不得不使用旧PHP版本。 因此,我无法使用所有新内容。 为了完成对场景的解释,没有一项测试。 我和团队中的任何人都不是原始扩展设计和开发的一部分。 一开始,大多数时候我们都迷路了。

圈内奔跑和尖叫不是一种选择 (Running in circles and screaming is not an option)

When you start working in a project like this, you feel like those guys playing the last song in the Titanic. Everything is falling apart, but you keep doing your job.

当您开始在这样的项目中工作时,您会感觉像是那些家伙正在播放《泰坦尼克号》中的最后一首歌。 一切都崩溃了,但是您继续做自己的工作。

The clients keep opening tickets, the problems never seem to be solved at all. Your boss ask for new features. You start blaming the platform, the code base (someone you don’t even know wrote and you start hating them for that). At this point you are deep down in the legacy hell.

客户不断开票,这些问题似乎根本没有解决。 您的老板要求新功能。 您开始责怪平台和代码库(甚至您都不认识的人都开始为此而恨之入骨)。 在这一点上,您已经陷入了地狱的深渊。

There are actually two things you can do here. The first one is to update your Linkedin profile, put a nice photo, tell a nice story about how good you are and start sending resumés. Looking for a new job, a job without legacy code (spoiler alert, this place does not exist) or you can stop, breath and make a plan to deal with that thing.

您实际上可以在这里做两件事。 第一个是更新您的Linkedin个人资料,贴上一张漂亮的照片,讲述一个关于自己的好故事,然后开始发送简历。 寻找新的工作,没有遗留代码工作(扰流警报,这个地方存在),或者你可以停止,呼吸和制定一个计划,以对付那个东西。

开始做一些事情 (Start doing something about it)

If you are in a scenario like this, you should start acting fast. If your code base is not under a source code version system (git, please) and your team does not use a tool to manage the tasks, maybe you should think about that Linkedin stuff. But if you have the minimum, start with the basic, remove the cruft.

如果您处于这种情况,则应该开始快速采取行动。 如果您的代码库不在源代码版本系统(请使用git)下,并且您的团队未使用工具来管理任务,则也许您应该考虑使用Linkedin。 但是,如果您有最低要求,请从基本开始,删除残留物 。

I’m pretty sure that there is deprecated code, code that is not reached at all, and code that was left behind. Just taking space and making things look like a lot worse than it actually is. Give that code a good look, tinker with it, fill it with break points and start getting rid of what is not being used. Make sure you are not doing anything stupid here and don’t exaggerate. Remember, there is no test yet, so only get rid of those methods you are completely sure are useless.

我很确定有不推荐使用的代码,根本没有到达的代码以及留下的代码。 仅占用空间并使事情看起来比实际情况差很多。 给该代码一个好的外观,修改它,用断点填充它并开始摆脱不被使用的内容。 确保您在这里没有做任何愚蠢的事情,并且不要夸大其词。 记住,还没有测试,所以只有摆脱那些完全确定没有用的方法。

Doing that, you’ll be more comfortable with your code base and you will probably feel more confident. After that, you will still have unnecessary code, but almost everything you have there has meaning, or is useful.

这样做,您将对代码库更加满意,并且可能会感到更加自信。 在那之后,您仍然会拥有不必要的代码,但是您在那里拥有的几乎所有东西都具有意义或有用。

The next step is to think about tests. There are several ways to test software. You can do unitary tests, integration tests, system tests, stress tests, and plenty more. They are great and should be used in the right time. But remember, you are in a critical moment here and you should start with what is really important. Functional tests.

下一步是考虑测试。 有几种测试软件的方法。 您可以进行整体测试,集成测试,系统测试,压力测试等等。 它们很棒,应该在正确的时间使用。 但是请记住,您现在处于关键时刻,应该从真正重要的事情开始。 功能测试。

I’m not the most skilled tester. Far from that. I still have a lot to learn and study. But as far as I know, functional tests (for web projects, at least) are the least invasive ones. You don’t have to create mocks, stubs, fakes, dummies. Your tests are going to interact with the browser and simulate the human interaction.

我不是最熟练的测试人员。 远非如此。 我还有很多东西要学习。 但是据我所知,功能测试(至少针对Web项目)是侵入性最小的测试。 您不必创建模拟,存根,假货,假人。 您的测试将与浏览器交互并模拟人工交互。

At this point you have a code base with only the code that is needed and few tests to help you stop adding new bugs with every new feature. It is a win-win situation. Now you can stop, breath and think more calmly.

此时,您的代码库仅包含所需的代码,并且几乎没有测试可帮助您停止在每个新功能中添加新的错误。 这是双赢的局面。 现在您可以停下来,喘口气,更加冷静地思考。

接下来是什么? (What next?)

With more time, less bugs and sanity in place, you can start tackling other problems. Have you thought about continuous integration? How is your team development workflow? If you are using git (which I hope), you could start planning your branches. Create a master branch, a develop branch, add new features through feature branches, hot fix branches, and so on.

有了更多的时间,更少的错误和理智的解决方案,您就可以开始解决其他问题。 您是否考虑过持续集成? 您的团队开发工作流程如何? 如果您正在使用git(希望如此),则可以开始计划分支。 创建一个master分支,一个develop分支,通过Feature分支,Hot Fix分支等添加新功能。

How is your continuous delivery? How are your versions created? If you have to do more than “pushing a button”, maybe it is time to think about that process. How could you make it more reliable, less error prone? Does your application generate enough logs? Could you improve that? Now it is time to create a better software, now it is up to you.

您如何连续交货? 如何创建您的版本? 如果您要做的不仅仅是“按下按钮”,也许是时候考虑一​​下该过程了。 您如何使它更可靠,更不易出错? 您的应用程序是否生成足够的日志? 你能改善吗? 现在该创建一个更好的软件了,这取决于您。

而已 (That’s it)

We are still working on our legacy, trying to make it better. Although we haven’t reached the ideal scenario yet, several things have changed. Now we have only the necessary code. The workflow for that particular extension is well defined. We have functional tests in place and the deployment process is getting better.

我们仍在努力处理我们的遗产,力求使其更好。 尽管我们还没有达到理想的情况,但是有些事情已经改变。 现在,我们只有必要的代码。 该特定扩展的工作流程已明确定义。 我们已经进行了功能测试,并且部署过程越来越好。

After changing that scenario and surviving the legacy hell, our team got the task to develop a new extension to the same old Magento 1.9. Any sane person would be angry about that, but I’m thinking it is the perfect moment to do the right thing. This is the chance to make all the complaints become best practices and create a piece of software with maintainability in mind. but this is a subject for another article.

在改变了这种情况并在旧地狱中幸存下来之后,我们的团队获得了为相同的旧版Magento 1.9开发新扩展的任务。 任何理智的人都会对此感到生气,但是我认为这是做正确的事情的最佳时机。 这是使所有投诉成为最佳做法并创建具有可维护性的软件的机会。 但这是另一篇文章的主题。

翻译自: https://www.freecodecamp.org/news/few-thoughts-on-legacy-hell-e229f76529e0/

调试代码遗留


http://lihuaxi.xjx100.cn/news/239674.html

相关文章

apache开启虚拟主机 并进行配置

sudo vi /etc/apache2/httpd.conf 进入 apache 配置文件 在配置文件中搜索 Virtual hosts 如图 把前面的#删掉 #为注释 sudo vi /etc/apache2/extra/httpd-vhosts.conf 打开虚拟主机配置文件对下面的一下代码进行复制并粘贴在下方并更改里面的一些内容 DocumentRoot …

魅族手机使用鸿蒙系统,魅族宣布接入华为鸿蒙系统,这应该是黄章最正确的决定...

安卓能有现在的成就一切源于苹果之外其它所有品牌都在使用,俗话讲“众人拾柴火焰高”就是这个道理。相对来讲华为鸿蒙要想做大做强必须有其它品牌支持才可以,如果华为自己一家使用是无法做到与苹果的iOS、谷歌的安卓相抗衡的。这就是为什么华为鸿蒙正式确…

DOCKER OVERLAY NETWORK consul 注册

下载 consul 二进制包并启动 wget https://releases.hashicorp.com/consul/0.9.2/consul_0.9.2_linux_amd64.zip unzip consul_0.9.2_linux_amd64.zip mv consul /usr/bin/consul && chmod x /usr/bin/consul nohup consul agent -server -bootstrap -ui -data-dir /va…

Unique Paths II

注意一个容易犯的错误&#xff1a;判断obstacleGrid是否为1时&#xff0c;else那部分不能少。因为如果不加&#xff0c;就会默认把那些值设置为0。 class Solution { public:int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {int height ob…

uber_Uber是如何制成的

uberby Dmytro Brovkin由Dmytro Brovkin Uber是如何制成的 (How Uber was made) Uber has transformed the world. Indeed, its inconceivable to think of a world without the convenience of the innovative ride sharing service. Tracing its origins in a market which …

2021年甘肃省副高考试成绩查询,2021年甘肃卫生资格考试成绩查询-中国卫生人才网...

国家卫生资格考试网为您发布 2021年甘肃卫生资格考试成绩查询-中国卫生人才网&#xff0c;同步中国卫生人才网信息&#xff1a;2021甘肃卫生资格成绩查询。更多关于卫生资格成绩,卫生资格考试,2021卫生资格考试,国家卫生资格成绩查询的信息内容&#xff0c;请关注国家卫生资格考…

怎么写shell脚本才能不耍流氓?

1、不记录日志的 SHELL 脚本就是耍流氓&#xff01; 我们经常在工作中会遇到一个苦恼的事情&#xff0c;一个 Shell 脚本到底干了什么&#xff0c;什么时候开始执行&#xff0c;什么时候结束的。尤其是数据库备份&#xff0c;我们想知道我们的 MySQL 数据库备份时间。所以给脚本…

es6 ... 添加属性_如何在10分钟内免费将HTTPS添加到您的网站,以及为什么您现在不止需要这样做......

es6 ... 添加属性by Ayo Isaiah通过Ayo Isaiah 如何在10分钟内免费将HTTPS添加到您的网站&#xff0c;以及为什么现在比以往更需要这样做 (How to add HTTPS to your website for free in 10 minutes, and why you need to do this now more than ever) Last week, Google ann…