Analogy vs Metaphor
Analogy and metaphors are both techniques to explain unknown ideas by comparing them to ideas that are known. What are the differences? Let's see...
Analogy is a more precise way to explain the meaning of something unknown by comparing it to something that is familiar. You can use definitions based on the logic and proportion between the things that are being compared.
Let me give an example; let's say you want to explain what the function of software is on a computer. Software is a set of instructions that need to be performed to arrive at a destination in order to bring you to a certain file. So by analogy you could use the relationship between the car and the driver.
An analogy would look something like:
'The function of software in a computer is like a driver bringing a passenger from point A to B with a car.'
They both perform tasks/instructions(software) using a vehicle)hardware) in order to get to a certain destination. There is a direct analogy(relation) between the two.
It's a more precise compared to using metaphors.
Metaphors are used to connect arbitrary ideas to trigger an emotion using words that are more visual and vivid. It is a way to compare things that are not logically or proportionally related. They convey subjective meaning in an artistic way. For example when you're trying to explain how happy you are you could use the candyshop metaphor:
'I feel so overwhelmed as if I'm standing in a candy shop.'
It's a technique that storytellers and poets use to capture attention and pull listeners into a different mental state. It is a way to bypass the difficulty of language to express what people feel.