While this might seem more like a piece of an easy task to others, it's honestly not easy for me. At this stage, I find myself wandering how best to version my functions/methods.
What does this mean?
I have a function that does one thing and one thing alone. It saves Contacts to a local DB e.g RealmDb. This function is named addContacts and it's pretty easy and straightforward until now.
Now I need to optimize this function, the issue is the function is called in so many parts of the code and I'm quite cautious of not breaking anything to I have decided not to touch the function but rather create a similar function with optimized functionality and then I will deprecate the first function.
The main issue is I am not sure how best to name this new function. I have decided to name my new function "AddContactsV1" and point to it as a replacement for the first function.
Does this make any sense and if there is a better way around this kindly share.
Previous:
/** * Add An Array of Contacts Once. * @deprecated refer to @function addContactsV1 */ async addContacts(constactsArray, callBack) { //enter code here } New:
/** * Saves contacts to local data storage for offline access. * @param constactsArray is the contacts array object to be saved. * @returns a promise with an empty resolved or rejected with possible reasons. */ addContactsV1(contactsArrayObject) { return new Promise((resolved, rejected)=>{ //enter code here }); }