There are two reasons we recommend to store node references in variables:
- At a glance, at the top of your class, you can see all the dependencies of the class. All the nodes that, if you change them, can break this code. The more complex your projects become, the more bugs it'll save you.
-
Calling get_node() (or $) on the fly has a small performance cost. It's fine to do here and there, but if you get used to doing that everywhere, especially in process callbacks or loops, it will start to eat some of your CPU as your code grows.