如何处理过于复杂的继承代码 [英] What to do with over-complicated inherited code

查看:58
本文介绍了如何处理过于复杂的继承代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我在软件公司获得经验后,我发现很难容忍代码结构不整齐,没有任何形式的架构或美感或清晰度,无论它是否有效,即做它应该做的事情.

Ever since I gained experience at a software house I have found it difficult to tolerate code not neatly structured, without any form of architecture or beauty or clarity whether or not it works i.e. does what its supposed to do.

我发现我总是陷入这样的重构代码中,有时自费"是我的舒适度与生产力困境所在.

I find I am always caught up in refactoring code like this sometimes "at my own expense" is where my comfort v productivity dilemma is.

根据您的经验,处理您继承的写得不好的代码的最快方法是什么?写你的或封装/重构那里的东西,费时吗?

What is the quickest way to deal with badly written code you inherit in your experience? Write yours or encapsulate / refactor what's there, time consumingly?

推荐答案

根据你有多少时间以及代码到底有多糟糕,场景范围从把它全部扔掉,从头开始重写所有内容它是并从丑陋中承受痛苦.

Depending on how much time you have and on how crappy the code really is, the scenario ranges from throw it all away and rewrite everything from scratch to leave it as it is and take the pain from the uglyness.

重写所有内容很可能不是一种选择,如果代码确实有效,即使它可能非常丑陋.但是,如果不进行重构,就不可能用新功能扩展该代码.慢慢来,做一些小的改变.经常编译和测试!

Rewriting everything is most likely not an option, if the code actually works, even though it might be very ugly. However, to expand that code with new features might be impossible without refactoring. Take your time and do small changes. Compile and test often!

如果代码既错误又丑陋并且您还需要引入新功能.那么考虑重写整个事情可能真的很值得.代码中只能有这么多意大利面,直到它变得无法管理.

If the code is both buggy and ugly and you need to introduce new features as well. Then it might be really worth it to consider rewriting the whole thing. There can only be so much spaghetti in the code, until it becomes unmanagable.

勇敢地去吧.如果你在编码时感觉不好和凌乱,因为代码丑陋和讨厌.只需开始一点一点地改变它,很快代码将是你的",你就会知道代码实际上做了什么,你让它成为你的领域:)

Go with your guts. If it feels bad and messy when you're coding, because the code is ugly and nasty. Just start changing it piece by piece, soon the code "will be yours", you will know what the code actally does, you're making it your territory :)

干杯!

这篇关于如何处理过于复杂的继承代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆