|
|
|
| Non-WTF Job: C++ Developer at Good Grievance (Ronkonkoma, NY) |
| « Announcement: WTF in Français | 1.22: Working For The Man » |
Sometimes you see some code and can feel the frustration of the original developer. Sometimes it's because of profanity-laden comments in the code, other times it's because you can tell that they were right on the brink of a major breakthrough, but gave up.
In this case from Oliver K., the developer did his research, found the right tools for the job, and started coding. He realized that the task would be best handled with interfaces and probably toiled for hours trying to figure them out, eventually checking in the following:
ISchedule schedule = ScheduleFactory
.GetSchedule(Convert.ToInt32(SchedulesList.SelectedValue));
IScheduledTask nextScheduledTask = null;
if (schedule is DailySchedule)
nextScheduledTask = ((DailySchedule)schedule)
.GetNextScheduledTask(startRunTime, true);
if (schedule is WeeklySchedule)
nextScheduledTask = ((WeeklySchedule)schedule)
.GetNextScheduledTask(startRunTime, true);
if (schedule is MonthlyByDateSchedule)
nextScheduledTask = ((MonthlyByDateSchedule)schedule)
.GetNextScheduledTask(startRunTime, true);
if (schedule is MonthlyByDaySchedule)
nextScheduledTask = ((MonthlyByDaySchedule)schedule)
.GetNextScheduledTask(startRunTime, true);
if (schedule is YearlySchedule)
nextScheduledTask = ((YearlySchedule)schedule)
.GetNextScheduledTask(startRunTime, true);
if (schedule is SpecificDatesSchedule)
nextScheduledTask = ((SpecificDatesSchedule)schedule)
.GetNextScheduledTask(startRunTime, true);
|
Yeah, using "else if" would make that code run way faster, especially if you optimize to put the common cases upfront. :)
|
|
Now that really makes me say WTF!
That's like inventing the wheel and trying to roll it SIDEWAYS!! |
| « Announcement: WTF in Français | 1.22: Working For The Man » |