为什么人们会使代码变得如此复杂 [英] Why People make the code so complicated

查看:97
本文介绍了为什么人们会使代码变得如此复杂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我查看一些开源项目的源代码,即Asterisk.NET时,它看起来如此复杂并让我害怕......我知道我可以用一些类完成相同的工作,并且有限的编码......但是当我打开这些类型的项目,我意识到,我甚至不知道它上面的任何东西...

我似乎永远无法改变任何东西......为什么人们会让它变得如此复杂,成千上万的课程和接口....

When I go through the sourcecode for some opensource Projects i.e, Asterisk.NET, It seems so complex and making me afraid... I know I can accomplish the same with some classes, and limited coding... But when I open these type of projects, I realize, I dont know even anything on it...
It seems I cannot ever change anything on it... Why people make it so complex with thousands of classes and interfaces ....

推荐答案

一般来说,要使它比其他选择更简单!



我们通常不会让事情比没有充分理由的事情更复杂。有时,这个原因是我们不知道更好,但总的来说,我们制造的东西比他们表面上需要的东西更复杂因为它们并不像看起来那么简单,或者我们希望允许未来的变化。我们也这样做是因为团队合作更容易,而不是单个人。



你可以做任何没有课程,没有接口,您甚至可以在汇编程序或机器代码中执行此操作,但随后代码的复杂性实际上会增加,因为事物之间的互连也会增加。添加类和接口可以更好地组织代码,因此它比单片代码更可靠,更易理解。



无论如何:这取决于最终产品是什么。有些东西原则上看起来非常简单,但在实践中却非常复杂。拿火箭:加油,轻便,升空!简单吧?现在看看土星V发射器并告诉我这很简单! :笑:相信我,美国宇航局没有添加任何他们没有的东西,因为发射成本随着质量成倍增长......
Generally, to make it less complicated than the alternative!

We don't normally make things more complex than they have to be without good reason. Sometimes, that reason is "we didn't know any better", but generally speaking we make things more complex than they seem to need on the surface because they aren't as simple as they seem, or we want to allow for future changes. We also do it because it is a lot easier to work on as a team, rather than as a single individual.

You can do anything without classes, without interfaces, you can even do it in assembler or machine code, but then the complexity of the code actually increases, because the interconnections between things increases as well. Adding classes and interfaces organises code better, so it is more reliable and understandable than a monolithic piece of code.

And anyway: it depends on what the end product is. Some things look really, really simple in principle, but in practice are hideously complicated. Take a rocket: fuel in, light, lift off! Simple, right? Now have a look at a Saturn V launcher and tell me that is simple! :laugh: And trust me, NASA didn't add anything they didn't have to because the launch costs go up exponentially with mass...


这篇关于为什么人们会使代码变得如此复杂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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