I had a discussion, if the code for calling information from a database can have a switch to show also deleted entries.
Simplyfied the code (C#) look like this:
void searchEntry(string searchValue, bool searchDelete = false)
Usually, the most part of the code base doesn't want to show up the deleted entries, but if you want to undelete an entry (and thats my only case) I want to get the deleted to look, if they should be undeleted.
I came to discussion that "boolean" should be avoided in this method,
Surely, I can make a enum like:
enum DeletionFlag {
DontSearchDeleted,
SearchDeleted
}
But makes this the code really more readble:
void searchEntry(string searchValue, DeletionFlag searchDelete = DeletionFlag.SearchDeleted)
The database table has a bool value for "isDeleted" to define, if the entry is marked as deleted.
So could use the kind of calls:
db.searchEntry("somesearch", DeletionFlag.DontSearchDeleted);
db.searchEntry("somesearch", DeletionFlag.SearchDeleted);
Would this be a better solution, or is it ok, to stay with boolean for this?
What are your suggestions?