The Decorator Design Pattern is a way to add new features to an object without changing its
structure or the original class. In this code, the UserManager class is improved with extra
functionality (logging) using this pattern.
How it works:
Core Class (UserManager)
The UserManager class handles the main tasks like adding, editing, removing, and
fetching users from the database.
It focuses only on these core functions and doesn't include any additional features.
Abstract Decorator (UserManagerDecorator)
UserManagerDecorator is a base class that wraps around UserManager.
It has the same methods as UserManager (like addUser, editUser, etc.), so it can replace
UserManager if needed.
This decorator class contains a reference to the original UserManager object and can pass
method calls to it while also adding new functionality.
Concrete Decorator (LoggingUserManagerDecorator)
This specific decorator, LoggingUserManagerDecorator, adds logging.
For example:
o When you use addUser, it logs the username of the user being added and then
calls the original addUser method.
o Similarly, editUser logs the username of the user being edited and then lets the
original UserManager handle the editing.