Should function parameter names be different from arguments?


#1

Right, so I have completed the challenge: triangle calculation. I get the correct answer and everything is fine.

However, I used angleA and angleB for my functions parameter names and angleC for the returned result. Looking at the previous Degrees program I see that parameter and argument names are different. Is this best practice and should I choose different names going forward?

Thanks


#2

Either way is fine. At this point, I’m making a point of always using different names for the parameters and the arguments. This is pedagogical: I want people to realize that they are different variables.

In reality, my arguments and parameters often have the same name. (After all, in my mind it is “angleA”. Why not use that name everywhere?) But in my heart I know that even though they have the same name, they are different variables because they are in different frames.


#3

Excellent explanation. Thank you :wink:


#4

Good clarification, I was having the same question.
This is great!
I am always looking over the forum, after finishing the chapters, and the reinforcement of the concepts is really helpful.