In many countries prostitution is as legal as software development. I think we should refrain from these jokes, especially since most do it out of a lack of alternative careers and to feed families.
I read it completely the opposite. The son looks down at the prostitute, but the father sees humanity in her and does not judge and treats her as a fellow person with dignity.
The son asks: "Father, why did you tip your hat to her? She's a prostitute, not a lady."
The father replies: "Son, you are correct, she is no lady. But I am a gentleman."