Ok...I will give you a couple of my favorite restaurants in Puglia/Matera; none of the Pugliese ones is in those cities but with a car you can reach them easily. Without a car, forget it.
CIBUS. Ceglie Messapica, about a 20 minute drive from Ostuni
ANTICHI SAPORI. Montegrosso, near Andria. Look at map; not a bad drive from Bari
MASSERIA BARBERA. Near Minervino Murge; worth the drive from Bari
TRATTORIA STANO. Matera
LA LOPA. Matera
LE ZIE. This has become famous in past ten years but still very good for Salento food in dining rooms that feel like a home.
ANTICA LOCANDA. Noci..easy 15-minute drive from Alberobello
MASSERIA GATTAMORA. Easy drive from Otranto in Uggiano la Chiesa; not as superb as the ones, above/below
RUA DE LI TRAVAI. Short drive from Novaglie in Patu
In Bari's we had a lovely meal at TERRANIMA; for focaccia Barese style, PANEFICIO RITA is quite a place; prepare for a line and try to have close to exact change. Many tourists, but really delicious. This is only one of a few great places for focaccia in the city; it's at the entrance to Bari Vecchia.
For spaghetti all'assassina, AL SORSO PREFERITO was good. I'm glad I tried this legendary Barese pasta but for me, I guess once is enough.