Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • My bad, I forgot to mention, my language does not support method overloading natively(Javascript). I use this in Java a lot and it saves me a headache. However, Javascript seems to give a few f about that. Commented Jun 28, 2021 at 17:18
  • @Wale Not being able to overload does make this a bit more difficult. Commented Jun 28, 2021 at 17:32
  • you're right, thank you. So, I have decided to change the name to something like saveContacts() and basically refer to it from the deprecated function. I will stick to this for now until I find a better way. Commented Jun 28, 2021 at 17:37
  • If signatures were exactly the same but for the number of arguments it would be easier but since both functions are different, I wouldn't strive to overload the function's name. An alternative could be checking if "callback" is set. If so, then execute the old code, if not, then execute the new one calling the new function. Once all the callers are migrated, you can remove the if and the old code. Commented Jun 29, 2021 at 8:24
  • 1
    @Wale JavaScript definitely allows equivalent of method overloading by checking parameters... whether it is good idea or not is an open question - worked wonders for JQuery (aka $). Commented Jun 29, 2021 at 18:21