Pattern or recommneded refactoring for method
- by iKode
I've written a method that looks like this:
public TimeSlotList processTimeSlots (DateTime startDT, DateTime endDT, string bookingType, IList<Booking> normalBookings, GCalBookings GCalBookings, List<DateTime> otherApiBookings) {
{
..... common process code ......
while (utcTimeSlotStart < endDT)
{
if (bookingType == "x")
{
//process normal bookings using IList<Booking> normalBookings
}
else if (bookingType == "y") {
//process google call bookings using GCalBookings GCalBookings
}
else if (bookingType == "z" {
//process other apibookings using List<DateTime> otherApiBookings
}
}
}
So I'm calling this from 3 different places, each time passing a different booking type, and each case passing the bookings I'm interested in processing, as well as 2 empty objects that aren't used for this booking type.
I'm not able to get bookings all into the same datatype, which would make this easier and each booking type needs to be processed differently, so I'm not sure how I can improve this.
Any ideas?