I think it is a good way to prevent one from committing sin or engaging in immorality. That is because when you consider the shame involved in way of consequences, you wouldn't want to do some despicable acts. For example, in many cultures, especially in Africa, it is taken as a shameful act when a lady gets pregnant outside of wedlock. It is seen as immoral and there's a stigma attached to her that goes even beyond the child birth. Most times, the parents may send the lady out of their home and will be of the notion that she's brought shame to the family.
She will be said to have put the family's name to mud. So, this will deter many female folks from engaging in such immoral acts just so the family value and good name is upheld.
Also, many families resort to extreme measures such as mercy killing where the kill the offender in the family in a bid to proclaim or cleanse the family name. I dont support mercy killing but it will be a good way of constraining oneself from engaging in acts that are regarded as immoral and sinful.
So, yes. I think the shame attached would serve as a deterrent to would-be offenders. I support the notion.
Thank you for asking.