At organizations where I have held the above titled roles, DNS was one of first things to be put into service if it had not already been used. Connecting to the IP address of a dedicated machine by a nice name is pretty much what the DNS was invented for. DNS is very much not static and if you are changing a host's IP very often, you can set it up such that the DNS responds appropriately with the proper up to date IP address.
OP's script is nice but... it's solving an already solved problem, IMO.
host alias hostName thehostname user your_username
I like the work in the article, but many times when I think I need to whip up a sweet script to fix some problem in the terminal I find the old neckbeards already wrote it, polished it, and left it on the shelf for me to use.