Architecture & LLD Preview
Visitor Pattern
Represent an operation to be performed on the elements of an object structure without modifying the classes of the elements.
Visitor pattern leverages double dispatch to delegate operations to dedicated calculation classes accepting element instances.
Core Design Challenge
"How do we apply new calculations to shopping cart items without adding operations directly to item classes?"
What You'll Learn:
- ✦Separating algorithms and operations from the objects they act on
- ✦Declaring double-dispatch accept() hooks in element classes
- ✦Adding new operations easily by implementing new visitor classes
- ✦Consolidating operation logic without bloating model objects