Skip to content

Check: Observer Pattern

Madeline Kahn edited this page Mar 11, 2024 · 4 revisions
  • Name: "observerPattern"
  • Default: Disabled

Configuration

Name Type Description
obsInterface boolean Specifies whether to check for interface subjects. Defaults to true.
obsAbstract boolean Specifies whether to check for abstract class subjects. Defaults to true.
obsConcrete boolean Specifies whether to check for patterns with only a concrete subject, and no abstract subject

Description

Iterates over every class, and checks to see if that class belongs to an observer pattern. Configuration parameters determine which "versions" of the observer pattern to use. More specifically, it checks if there is an interface/abstract/(none for concrete) subject, that depends-on/has-a/(N/a) interface or abstract observer. Then it checks that observer for any implementing classes, and checks if those classes have-a concrete subject. Then it checks if that concrete subject has-a interface / abstract observer. The patterns that satisfy that are returned, including all concrete subjects and observers. It does not check for names, since they don't always reflect this pattern, or methods, since I think it is possible to change the methods in the "normal" observer pattern while still keeping it an observer pattern. I check for concrete observer patterns because a few times in this class I have had that without feeling like I needed an abstract or interface subject.