本文介绍了意大利面条代码的特点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人说,当你的PHP代码和应用程​​序使用全局变量,那么它必须是意粉代码(我假设这)。我使用WordPress很多。据我所知,这是附近伟大的PHP软件最好的事情。它使用许多全局变量在其组件之间交互。



但是忘记了,坦率地说,这是我唯一知道的。因此,它完全有偏见; D



所以,我只是好奇,意大利面条代码的特征是什么? b

PS:我唯一知道的是WordPress。所以,希望,也许这将帮助一个人给一个很好的回答,谁有一点在PHP开发一个完整的Web应用程序的经验(例如,Stack Overflow网站)。

解决方案


  • 没有模块化(一个文件,类,模块,命名空间,您的语言使用提供模块化),

  • 大量 goto 的,

  • 组织,

  • 没有明确的功能和目的分开。




  • 代码的实现和客户端之间没有明确的接口合约。 (即,没有规定函数的输入,输出,前置和后置条件)

  • 过分依赖具有少量抽象的数据结构的内部。

  • 函数随机置换/修改全局状态,而不在文档中提及。

  • 缺少非平凡代码的注释或文档。

  • 代码比它需要的更复杂。

  • 缺乏重用。 (大量重复代码,又名)

  • 没有验证或单元测试(以信心工作)。

  • 魔法数字。



在本质上,缺乏设计和
预想,只是一个mishmash的
黑客砸在一起。这适用于任何语言,而不仅仅是PHP。对于在PHP上开发完整Web应用程序方面没有什么经验的人来说,

只是FYI,但Stack Overflow不是用PHP开发的。


Somebody said that when your PHP code and application use global variables then it must be spaghetti code (I assume this). I use WordPress a lot. As far as I know, it's the best thing near great PHP software. And it uses many global variables to interact between its components.

But forget about that, because frankly, that's the only thing I know. So it's completely biased ;D

So, I am just curious, What is the characteristic of spaghetti code?

PS: the only thing I know is WordPress. So, hopefully, maybe this will help somebody give a great answer for somebody who has little experience in developing a full web application on PHP (for example, the Stack Overflow website).

解决方案

  • No modularity (everything in one file, class, module, namespace, package, or whatever your language uses to provide modularity),
  • Plenty of goto's,
  • Poor organization,
  • No clear separation of functionality and purpose. (That is, all-encompassing classes or functions)
  • Long functions.
  • Poor naming.
  • No consistent coding style throughout.
  • No clear interface contract between implementation and clients of code. (That is, no specification of what the inputs, outputs, pre- and post-conditions of functions are)
  • Over-reliance on internals of data structures with little abstraction.
  • Functions randomly permute/modify global state without any mention of it in documentation.
  • Lack of comments or documentation of non-trivial code.
  • Code that is more complicated than it needs to be.
  • Lack of reuse. (plenty of duplicated code, a.k.a. copypasta)
  • No verification or unit testing (it works on faith).
  • Magic numbers.

In essence, a lack of design andforethought, and just a mishmash ofhacks slapped together. This applies to any language, not just PHP.

Just FYI, but Stack Overflow was not developed with PHP.

这篇关于意大利面条代码的特点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 02:00