On behalf of the deceased

Charity can be made on behalf of the deceased. Ibn ‘Abbas narrates that a man asked: “O Messenger of Allah, my mother died; will it benefit her if I give in charity on her behalf?” He (PBUH) said: “Yes.” (An-Nasai)

The Prophet (PBUH) told us that water is the best charity. (An-Nasai). Building a water well in the name of the deceased is, therefore, a very good investment for them because it is considered a  sadaqah jariyyah on their behalf providing clean drinking water to those most in need.