I'm hoping to go to Bari, Lecce, and Matera for 10 days in late January-early February. It might be a bit cold but far warmer than where I'm from. I am trying to decide whether to visit Matera from Bari as a day trip (arriving early and leaving after sunset) or to stay there for two nights. My hesitation is that the route from Matera to Lecce seems weirdly long (four or more hours by bus). I love art, architecture, photography, walking.
Matera is amazing! Considering that you’re going in Winter, I would at least stay overnight. Make it count even more by staying in a B&B in a cave. : ). I chose my dates for Matera based on the availability of a special B&B, Palazzo Degli Abati. While I was on the fence about coming to this city, this B&B was definitely the tipping point. Being there, it was absolutely perfect! I reserved directly with them, selecting the Junior Suite in Grotta - Senza Nidd.
To break up your travel to Lecce, consider staying a night in Monopoli. I recommend most sites there but would skip the interior of the castle.
What are you arrival/departure points? You might be able to rework the order--for example from Bari airport to Matera there is a direct bus (and Bari to Matera is not too onerous otherwise), so you could potentially start in Matera, then going from Bari to Lecce will be less of a slog (just two hours). If that does not work out, then I would do as Jean suggested and break up the trip with a stop.
I would try to overnight in Matera if possible.