The Visitor Design Pattern

Description Adding new methods within subclasses works fine if the program being developed isn’t complex - simply add the methods to each of the individual subclasses. For example, if we have an Animal parent class, each of the Animal subclasses may need to implement a makeSounds() method. However, when our codebase consists of dozens of new methods to be implemented for dozens of subclasses, the code within each subclass becomes cluttered and often becomes difficult to maintain....

August 13, 2023 · 4 min