“烤宽面条代码”这个词对你意味着什么?

时间:2022-07-23 16:54:52

According to Wikipedia, the term was originally coined by a database expert Joe Celko in 1982 and here's a quote from his 1997 article revealing what he meant by it: "The standard [structured programming] solution was to replace the GOTOs with nested IF-THEN-ELSE statements and switches that were layered so deep and had so much redundancy that you had a path of control that looked like a plate of lasagna instead."

根据*的说法,该术语最初是由数据库专家Joe Celko在1982年创造的,这里引用了他1997年的文章,揭示了他的意思:“标准[结构化编程]解决方案是用嵌套的IF-THEN替换GOTO -ELSE语句和交换机分层如此之深,冗余太多,你有一个控制路径,看起来像一盘烤宽面条。“

The same Wikipedia entry however, defines the term differently, clearly referring to multi-layered applications: "... different subsystems, such as ... web application code, business logic, and a relational database." The term's meaning has thus evolved as programmers developed new methodologies and architectures.

然而,相同的*条目定义了不同的术语,明确指的是多层应用程序:“......不同的子系统,例如...... Web应用程序代码,业务逻辑和关系数据库。”因此,随着程序员开发新的方法和体系结构,术语的含义也随之发展。

I can think of two modern definitions of "lasagna code":

我可以想到两个“烤宽面条代码”的现代定义:

  1. layers of a software application that are excessive, over-engineered or trivial (obviously)
  2. 过度,过度设计或微不足道的软件应用程序层(显然)

  3. layers of a software application lacking unit tests with proper isolation. The developers only tested the system by slicing through and consuming multiple layers at once.
  4. 软件应用程序的各个层,缺少适当隔离的单元测试。开发人员仅通过一次切片并消耗多个层来测试系统。

The term obviously means criticism (much like you may criticize my stuff by calling it "spaghetti code"). But what does it mean to you and when would you use it?

这个词显然意味着批评(就像你可以通过称之为“意大利面条代码”来批评我的东西)。但这对你意味着什么,你什么时候使用它?

5 个解决方案

#1


To me, it means layered for no good reason.

对我来说,这意味着无缘无故地分层。

#2


Too many GOTOs == Spaghetti Code

太多的GOTO == Spaghetti Code

Too many IF-THEN-ELSE/Switch == Lasagna Code

太多IF-THEN-ELSE / Switch == Lasagna Code

:)

#3


Spaghetti code reference at Wikipedia has this to say,

*的Spaghetti代码参考说明了这一点,

Lasagna code is a type of program structure, characterized by several well-defined and separable layers, where each layer of code accesses services in the layers below through well-defined interfaces.
The term is in comparison with spaghetti code, comparing program structure to pasta.

Lasagna代码是一种程序结构,其特征在于几个明确定义且可分离的层,其中每层代码通过定义良好的接口访问下面层中的服务。该术语与意大利面条代码相比较,将程序结构与面食进行比较。

The analogy stems from the layered structure of a plate of lasagna,
where different ingredients (meat, sauce, vegetables, or cheese) are each separated by strips of pasta.

这个类比源于一盘烤宽面条的分层结构,其中不同的成分(肉,酱汁,蔬菜或奶酪)各自被意大利面条隔开。

#4


A well made lasagna, the kind my wife makes, is well layered and neat, spaghetti on the other hand is a tangled confusing mess, so I would think that the latter would be an insult while the former would just be a way of describing code that has been developed in isolated layers. I guess MVC would be considered a lasagna approach to programming, but it sounds silly and I would never use it. Besides, if you told a fat programmer that he writes lasagna applications you run the risk of offending the poor guy.

一个做得很好的烤宽面条,我妻子做的那种,很好的分层和整洁,另一方面,意大利面是一个混乱的混乱,所以我认为后者将是一种侮辱,而前者只是一种描述代码的方式这是在孤立的层中开发的。我猜MVC会被认为是编程的一种烤宽面条,但听起来很傻,我永远不会使用它。此外,如果你告诉一个胖胖的程序员,他写了烤宽面条应用程序,你就有冒犯这个可怜人的风险。

It could also refer to code written by italians I suppose :)

它也可以参考意大利人写的代码我想:)

#5


I've never heard of lasagna code before, but the first thing that came to mind was "spaghetti code". My guess was parts of it were all over the place, but the majority was a cohesive unit. Not a bad a spaghetti code, but not good enough not to get called out.

我之前从未听说过烤宽面条代码,但首先想到的是“意大利面条代码”。我的猜测是它的一部分都到处都是,但大多数是一个有凝聚力的单位。意大利面条代码也不错,但还不够好,不会被叫出来。

#1


To me, it means layered for no good reason.

对我来说,这意味着无缘无故地分层。

#2


Too many GOTOs == Spaghetti Code

太多的GOTO == Spaghetti Code

Too many IF-THEN-ELSE/Switch == Lasagna Code

太多IF-THEN-ELSE / Switch == Lasagna Code

:)

#3


Spaghetti code reference at Wikipedia has this to say,

*的Spaghetti代码参考说明了这一点,

Lasagna code is a type of program structure, characterized by several well-defined and separable layers, where each layer of code accesses services in the layers below through well-defined interfaces.
The term is in comparison with spaghetti code, comparing program structure to pasta.

Lasagna代码是一种程序结构,其特征在于几个明确定义且可分离的层,其中每层代码通过定义良好的接口访问下面层中的服务。该术语与意大利面条代码相比较,将程序结构与面食进行比较。

The analogy stems from the layered structure of a plate of lasagna,
where different ingredients (meat, sauce, vegetables, or cheese) are each separated by strips of pasta.

这个类比源于一盘烤宽面条的分层结构,其中不同的成分(肉,酱汁,蔬菜或奶酪)各自被意大利面条隔开。

#4


A well made lasagna, the kind my wife makes, is well layered and neat, spaghetti on the other hand is a tangled confusing mess, so I would think that the latter would be an insult while the former would just be a way of describing code that has been developed in isolated layers. I guess MVC would be considered a lasagna approach to programming, but it sounds silly and I would never use it. Besides, if you told a fat programmer that he writes lasagna applications you run the risk of offending the poor guy.

一个做得很好的烤宽面条,我妻子做的那种,很好的分层和整洁,另一方面,意大利面是一个混乱的混乱,所以我认为后者将是一种侮辱,而前者只是一种描述代码的方式这是在孤立的层中开发的。我猜MVC会被认为是编程的一种烤宽面条,但听起来很傻,我永远不会使用它。此外,如果你告诉一个胖胖的程序员,他写了烤宽面条应用程序,你就有冒犯这个可怜人的风险。

It could also refer to code written by italians I suppose :)

它也可以参考意大利人写的代码我想:)

#5


I've never heard of lasagna code before, but the first thing that came to mind was "spaghetti code". My guess was parts of it were all over the place, but the majority was a cohesive unit. Not a bad a spaghetti code, but not good enough not to get called out.

我之前从未听说过烤宽面条代码,但首先想到的是“意大利面条代码”。我的猜测是它的一部分都到处都是,但大多数是一个有凝聚力的单位。意大利面条代码也不错,但还不够好,不会被叫出来。