Pattern or recommneded refactoring for method

Posted by iKode on Stack Overflow See other posts from Stack Overflow or by iKode
Published on 2012-06-22T10:06:42Z Indexed on 2012/06/22 15:16 UTC
Read the original article Hit count: 211

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about oop

Related posts about design-patterns