What would be a sensible thing to do with someone who had committed a crime? assuming we wanted them to not commit more crimes in the future

Send them to a big house full of other people who have committed crimes and hope they don’t learn any new and interesting ways to do crimes?

I am definitely not a domain expert, but something is telling that perhaps that’s really fucking stupid.