What is a good analogy for pass by value vs by reference? In general, there are two ways arguments can be passed to a function. Functions can either be passed a reference to an object, or the value of that object. This is something that my students often struggle to understand, and I struggle to explain.

What are some good analogies for pass by reference and pass by value? What are some pseudo-code (or real code) examples I could show that would function differently in a pass by reference language and a pass by value language?

This is already covered on Stack Overflow, but I'd like to get some answers more specifically about how to teach it and less about what the designation is.
Since I was tired of the easy IT examples which all revolved around sharing files and documents, I started using the following analogies to explain pass by value and by reference.

My cat ("Mr Doorknob") sometimes wanders off to my neighbour. They call him "Cirmi", but of course he is still the same cat. If they feed him, he comes home fat and satisfied, if their dog licks him, he comes home covered in saliva.
This is a bit like passing a variable by reference: they might give him a different name, but it is the same cat. Whatever is done to the passed cat in the neighbour's garden will be visible on the cat when he finally comes home. (I actually like this because it helps them understand the "different name thing".)

As for passing by value, my neighbours really liked my new sunshade. They asked me where I got it from, and they bought one themselves. It looked identical in the beginning, but theirs got pooped on by a bird. This, obviously, didn't affect mine, it is still as shiny and clean as it was.



Many things can be used as analogy for pass by reference: renting books from a library, and seeing the marks in it someone else made; lending some item to a friend, etc.
I find it harder to come up with real life examples for passing by value, but one example is photo copying course notes, or artists (or forgers) copying famous paintings.

So, lending someone my course notes VS letting them make a copy of my course notes, then see them pour coffee over the notes while they are learning from it - in case one, my originals are ruined, in case two, my originals are safe. (Instead of pouring coffee, we can have them add improvements/comments to the notes, to make it positive instead of negative).