bloated class 和 tagged class 有什么区别?

what is the difference between bloated class and tagged class?

正如我在 Effective java

中读到的

Bloated class hierarchies can lead to bloated classes containing many methods that differ only in the type of their arguments, as there are no types in the class hierarchy to capture common behaviors.

并在 Link

A bloated class often has many special cases: attributes or behavior valid for some instances but not others. Often programmers attempt to deal with special cases by introducing type tags.

标记的 class 与臃肿的 class 之间存在相似性,如 Effective java 中提到的:

a class whose instances come in two or more flavors and contain a tag field indicating the flavor of the instance. instances are burdened with irrelevant fields belonging to other flavors.

所以总结 classes 可能有 Tag Types/Fieldsboth classes 都有这么多的实现(在一个 class 中模拟了这么多功能)。

我对这些术语感到困惑,我想知道这两个 Bloated class 和 Tagged class 之间有什么区别?

  • 臃肿 class 臃肿(见下文)。
  • 一个标记 class 有一个或多个标记。
  • 标记的 class 可能是肿的,肿的 class 不一定是标记的。

"Bloated" 是(有点)主观的,"tagged" 是微不足道的识别。 "Bloat" 可以指代很多东西;关注点分离不佳、缺少封装、不同层次的抽象等等。

"Tagged"主观性较低,因为会有一个字段定义功能分离、抽象等