I'm creating an interface to record navigation history.
First thing is, we have three types of records: Recordable (the default behaviour), Revisitable (a user can look at their history and revisit that item), and Traversible (the user can simply "go back"). Traversible records are, by definition, Revisitable which are, in turn, Recordable. These types are encoded in an enum.
Each record contains the information needed to restore the view to a particular state. Our design is modular and action based - some actions take parameters. So, the history needs to record the module and action at a minimum - and sometimes the action parameters, and sometimes the recordType (if not the default), and sometimes both.
This leads me to:
void recordAction(const QString &moduleName, const QString &actionName);
void recordAction(const QString &moduleName, const QString &actionName, QVariantMap parameters);
void recordAction(const QString &moduleName, const QString &actionName, QVariantMap parameters, int recordType);
void recordAction(const QString &moduleName, const QString &actionName, int recordType);
Is this a good pattern? Or should I implement something more like:
void recordAction(const QString &moduleName, const QString &actionName, QVariantMap parameters = QVariantMap());
void recordRevisitableAction(const QString &moduleName, const QString &actionName, QVariantMap parameters = QVariantMap());
void recordTraversibleAction(const QString &moduleName, const QString &actionName, QVariantMap parameters = QVariantMap());
I guess, ultimately, these methods will simply call an internal:
void recordAction(const QString &moduleName, const QString &actionName, QVariantMap parameters, int recordType);
So, which is the better pattern to follow? While I don't see a need yet, there may be another type of record I haven't thought of...