Design Pattern & Dispatcher Model

SmartShelf uses a Dispatcher Pattern to decouple UI choices from functional logic. This improves modularity, scalability, and maintainability.

Dispatcher Table


choice_handlers = {
    'View Pantry': render_pantry,
    'Edit Pantry Quantities': render_edit_pantry,
    'Add to Pantry': render_pantry_update,
    'Expired Items': render_expired_items,
    'Exit': exit_app
}

Each menu button maps to a dedicated handler function. Adding new functionality requires only:

Controller Logic


def handle_choice(choice):
    handler = choice_handlers.get(choice)
    if handler:
        handler()

This design removes conditional branching and centralizes control logic.

Architectural Benefit

← Back to Index