Do you often use Overloaded methods or you try to avoid them?
I keep getting into this dilemma, especially because I want to use Overload instead of unique method names, but eventually overloaded methods become too complex.
For example:
Let's say we have TaskScheduler class and it needs methods to add tasks, and here how it started:
TTaskAction = (taNa, taExecuteNow, taExecuteDelayed, taQueueTaskOnly...);
procedure AddTask(aAction: TTaskAction; aTask: TTask); overload; // Execute aTask immeditaly
procedure AddTask(aAction: TTaskAction; aTask: TTask; aExecDateTime: TDateTime; aAllowImmediateExec: boolean); overload; // Execute aTask at set date time
procedure AddTask(aAction: TTaskAction; aTask: TTask; aQueueOnly: boolean); overload; // Put aTask to Queue and wait for execution
this looks good, but as soon as you start adding more info for each TTaskAction, it become a mess because some parameters get passed empty, depending on which TTaskAction is being used for.
This is easy solved if I use AddImmediateTask, AddDelayedTask and AddTaskToQueue methods. Then no mess.
Any recommendations how to approach this or should I just use overloaded methods for very simple cases?