Keep sending a string without breaking changes on this NPM library












0















A little bit of backstory:



We're trying to address a bug on a local library we have.



I was trying to convince the senior developers of changing naming convention when using word like these:




enable disable hide unhide




because they were using




enable disable hide undelete




We discussed the fact of this being a breaking change and will stop other products from working.



So it was disscused to add the unhide without taking the undelete out so that it does not break anything and in the process, if the user uses either unhide or undelete they should still do the same in theory.



Here comes the programming problem now:



This is my function:



toggleAction(data._id, 'undelete', (err, data) => { // cool stuff }, false)


How can I continue to pass a string (without converting to an array or object) but also start passing 2 values so that the changes have to be made in this file and not in the projects side validating, etc.



Another thing, this function will default if the switch case does not found the string.



Also thought about sending two request at the same time but that's just bad programming.



Also though of fallback to another request with the other naming, but since the switch case will still default if it's not in the options, it will not throw an error to actually do the callback for the next function.



What do you guys think is the right approach for something simple and yet capable of breaking a lot of things.



Thanks in advance.










share|improve this question























  • Hi @christopher, I lost you after you started talking about the function. What exactly is the problem you are facing? I am unable to understand.

    – theapologist
    Nov 15 '18 at 16:31











  • simple question: I want to keep passing a string in toggleAction(id, 'theString", etc..) But this string, should have at least 2 values when being read in the applications using it. I can't pass an array or an object, because this will break a lot of things. I would like a clean approach for making: toggleAction(data._id, 'undelete', (err, data) => { // cool stuff }, false) toggleAction(data._id, 'unhide', (err, data) => { // cool stuff }, false) But of course, instead of doing 2 calls make one with the 2 values. It's tricky.. cause i dont see any other way without using object

    – christopher de jesus
    Nov 15 '18 at 16:35











  • Just so that I know we are talking about the same thing, you want to pass a string to the function, but the string should have two values? ie; the string should be able to be read as either unhide or undelete?

    – theapologist
    Nov 15 '18 at 16:38











  • @LloydFrancis exactly. I know it's crazy.

    – christopher de jesus
    Nov 15 '18 at 16:39











  • Yeah that's pretty crazy. Just a question, why don't you use undelete for the function call in the first place? Assuming that you cannot change anything in the library, perhaps you can use unhide in your code and change it to undelete only when you have to make the function call?

    – theapologist
    Nov 15 '18 at 16:42
















0















A little bit of backstory:



We're trying to address a bug on a local library we have.



I was trying to convince the senior developers of changing naming convention when using word like these:




enable disable hide unhide




because they were using




enable disable hide undelete




We discussed the fact of this being a breaking change and will stop other products from working.



So it was disscused to add the unhide without taking the undelete out so that it does not break anything and in the process, if the user uses either unhide or undelete they should still do the same in theory.



Here comes the programming problem now:



This is my function:



toggleAction(data._id, 'undelete', (err, data) => { // cool stuff }, false)


How can I continue to pass a string (without converting to an array or object) but also start passing 2 values so that the changes have to be made in this file and not in the projects side validating, etc.



Another thing, this function will default if the switch case does not found the string.



Also thought about sending two request at the same time but that's just bad programming.



Also though of fallback to another request with the other naming, but since the switch case will still default if it's not in the options, it will not throw an error to actually do the callback for the next function.



What do you guys think is the right approach for something simple and yet capable of breaking a lot of things.



Thanks in advance.










share|improve this question























  • Hi @christopher, I lost you after you started talking about the function. What exactly is the problem you are facing? I am unable to understand.

    – theapologist
    Nov 15 '18 at 16:31











  • simple question: I want to keep passing a string in toggleAction(id, 'theString", etc..) But this string, should have at least 2 values when being read in the applications using it. I can't pass an array or an object, because this will break a lot of things. I would like a clean approach for making: toggleAction(data._id, 'undelete', (err, data) => { // cool stuff }, false) toggleAction(data._id, 'unhide', (err, data) => { // cool stuff }, false) But of course, instead of doing 2 calls make one with the 2 values. It's tricky.. cause i dont see any other way without using object

    – christopher de jesus
    Nov 15 '18 at 16:35











  • Just so that I know we are talking about the same thing, you want to pass a string to the function, but the string should have two values? ie; the string should be able to be read as either unhide or undelete?

    – theapologist
    Nov 15 '18 at 16:38











  • @LloydFrancis exactly. I know it's crazy.

    – christopher de jesus
    Nov 15 '18 at 16:39











  • Yeah that's pretty crazy. Just a question, why don't you use undelete for the function call in the first place? Assuming that you cannot change anything in the library, perhaps you can use unhide in your code and change it to undelete only when you have to make the function call?

    – theapologist
    Nov 15 '18 at 16:42














0












0








0








A little bit of backstory:



We're trying to address a bug on a local library we have.



I was trying to convince the senior developers of changing naming convention when using word like these:




enable disable hide unhide




because they were using




enable disable hide undelete




We discussed the fact of this being a breaking change and will stop other products from working.



So it was disscused to add the unhide without taking the undelete out so that it does not break anything and in the process, if the user uses either unhide or undelete they should still do the same in theory.



Here comes the programming problem now:



This is my function:



toggleAction(data._id, 'undelete', (err, data) => { // cool stuff }, false)


How can I continue to pass a string (without converting to an array or object) but also start passing 2 values so that the changes have to be made in this file and not in the projects side validating, etc.



Another thing, this function will default if the switch case does not found the string.



Also thought about sending two request at the same time but that's just bad programming.



Also though of fallback to another request with the other naming, but since the switch case will still default if it's not in the options, it will not throw an error to actually do the callback for the next function.



What do you guys think is the right approach for something simple and yet capable of breaking a lot of things.



Thanks in advance.










share|improve this question














A little bit of backstory:



We're trying to address a bug on a local library we have.



I was trying to convince the senior developers of changing naming convention when using word like these:




enable disable hide unhide




because they were using




enable disable hide undelete




We discussed the fact of this being a breaking change and will stop other products from working.



So it was disscused to add the unhide without taking the undelete out so that it does not break anything and in the process, if the user uses either unhide or undelete they should still do the same in theory.



Here comes the programming problem now:



This is my function:



toggleAction(data._id, 'undelete', (err, data) => { // cool stuff }, false)


How can I continue to pass a string (without converting to an array or object) but also start passing 2 values so that the changes have to be made in this file and not in the projects side validating, etc.



Another thing, this function will default if the switch case does not found the string.



Also thought about sending two request at the same time but that's just bad programming.



Also though of fallback to another request with the other naming, but since the switch case will still default if it's not in the options, it will not throw an error to actually do the callback for the next function.



What do you guys think is the right approach for something simple and yet capable of breaking a lot of things.



Thanks in advance.







javascript string






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 16:23









christopher de jesuschristopher de jesus

1228




1228













  • Hi @christopher, I lost you after you started talking about the function. What exactly is the problem you are facing? I am unable to understand.

    – theapologist
    Nov 15 '18 at 16:31











  • simple question: I want to keep passing a string in toggleAction(id, 'theString", etc..) But this string, should have at least 2 values when being read in the applications using it. I can't pass an array or an object, because this will break a lot of things. I would like a clean approach for making: toggleAction(data._id, 'undelete', (err, data) => { // cool stuff }, false) toggleAction(data._id, 'unhide', (err, data) => { // cool stuff }, false) But of course, instead of doing 2 calls make one with the 2 values. It's tricky.. cause i dont see any other way without using object

    – christopher de jesus
    Nov 15 '18 at 16:35











  • Just so that I know we are talking about the same thing, you want to pass a string to the function, but the string should have two values? ie; the string should be able to be read as either unhide or undelete?

    – theapologist
    Nov 15 '18 at 16:38











  • @LloydFrancis exactly. I know it's crazy.

    – christopher de jesus
    Nov 15 '18 at 16:39











  • Yeah that's pretty crazy. Just a question, why don't you use undelete for the function call in the first place? Assuming that you cannot change anything in the library, perhaps you can use unhide in your code and change it to undelete only when you have to make the function call?

    – theapologist
    Nov 15 '18 at 16:42



















  • Hi @christopher, I lost you after you started talking about the function. What exactly is the problem you are facing? I am unable to understand.

    – theapologist
    Nov 15 '18 at 16:31











  • simple question: I want to keep passing a string in toggleAction(id, 'theString", etc..) But this string, should have at least 2 values when being read in the applications using it. I can't pass an array or an object, because this will break a lot of things. I would like a clean approach for making: toggleAction(data._id, 'undelete', (err, data) => { // cool stuff }, false) toggleAction(data._id, 'unhide', (err, data) => { // cool stuff }, false) But of course, instead of doing 2 calls make one with the 2 values. It's tricky.. cause i dont see any other way without using object

    – christopher de jesus
    Nov 15 '18 at 16:35











  • Just so that I know we are talking about the same thing, you want to pass a string to the function, but the string should have two values? ie; the string should be able to be read as either unhide or undelete?

    – theapologist
    Nov 15 '18 at 16:38











  • @LloydFrancis exactly. I know it's crazy.

    – christopher de jesus
    Nov 15 '18 at 16:39











  • Yeah that's pretty crazy. Just a question, why don't you use undelete for the function call in the first place? Assuming that you cannot change anything in the library, perhaps you can use unhide in your code and change it to undelete only when you have to make the function call?

    – theapologist
    Nov 15 '18 at 16:42

















Hi @christopher, I lost you after you started talking about the function. What exactly is the problem you are facing? I am unable to understand.

– theapologist
Nov 15 '18 at 16:31





Hi @christopher, I lost you after you started talking about the function. What exactly is the problem you are facing? I am unable to understand.

– theapologist
Nov 15 '18 at 16:31













simple question: I want to keep passing a string in toggleAction(id, 'theString", etc..) But this string, should have at least 2 values when being read in the applications using it. I can't pass an array or an object, because this will break a lot of things. I would like a clean approach for making: toggleAction(data._id, 'undelete', (err, data) => { // cool stuff }, false) toggleAction(data._id, 'unhide', (err, data) => { // cool stuff }, false) But of course, instead of doing 2 calls make one with the 2 values. It's tricky.. cause i dont see any other way without using object

– christopher de jesus
Nov 15 '18 at 16:35





simple question: I want to keep passing a string in toggleAction(id, 'theString", etc..) But this string, should have at least 2 values when being read in the applications using it. I can't pass an array or an object, because this will break a lot of things. I would like a clean approach for making: toggleAction(data._id, 'undelete', (err, data) => { // cool stuff }, false) toggleAction(data._id, 'unhide', (err, data) => { // cool stuff }, false) But of course, instead of doing 2 calls make one with the 2 values. It's tricky.. cause i dont see any other way without using object

– christopher de jesus
Nov 15 '18 at 16:35













Just so that I know we are talking about the same thing, you want to pass a string to the function, but the string should have two values? ie; the string should be able to be read as either unhide or undelete?

– theapologist
Nov 15 '18 at 16:38





Just so that I know we are talking about the same thing, you want to pass a string to the function, but the string should have two values? ie; the string should be able to be read as either unhide or undelete?

– theapologist
Nov 15 '18 at 16:38













@LloydFrancis exactly. I know it's crazy.

– christopher de jesus
Nov 15 '18 at 16:39





@LloydFrancis exactly. I know it's crazy.

– christopher de jesus
Nov 15 '18 at 16:39













Yeah that's pretty crazy. Just a question, why don't you use undelete for the function call in the first place? Assuming that you cannot change anything in the library, perhaps you can use unhide in your code and change it to undelete only when you have to make the function call?

– theapologist
Nov 15 '18 at 16:42





Yeah that's pretty crazy. Just a question, why don't you use undelete for the function call in the first place? Assuming that you cannot change anything in the library, perhaps you can use unhide in your code and change it to undelete only when you have to make the function call?

– theapologist
Nov 15 '18 at 16:42












1 Answer
1






active

oldest

votes


















0














Kinda opinion based, but it's the wrong approach imho.
I would change the word undelete to unhide only on the rendered websites and keep the internal API the same way until the senior devs can fix the breaking changes.
So the user would see the word 'unhide' on their screen, but the API will still stay 'undelete'.



In more complex applications, you'd use an enumeration list so you can change the labels as many times as you want:



const enum_options = [
'enable',
'disable',
'hide',
'show'
];
// 3 is the index of the word 'show'
toggleAction(data._id, 3, (err, data) => { // cool stuff }, false)


That way the API never has to change when you change the labels to any word you desire. Which will also help alot if you ever have to support multiple languages.



ps:



1) if this is a breaking change, there's an issue with the architecture used.
Fix the issues instead of adding even more fragile code. Switching to like using a string 'undelete-unhide' will still need alot of api changes if the entire app has the word 'undelete' written everywhere at the moment.



2) The opposite of hide is usually 'show', not unhide.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323783%2fkeep-sending-a-string-without-breaking-changes-on-this-npm-library%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Kinda opinion based, but it's the wrong approach imho.
    I would change the word undelete to unhide only on the rendered websites and keep the internal API the same way until the senior devs can fix the breaking changes.
    So the user would see the word 'unhide' on their screen, but the API will still stay 'undelete'.



    In more complex applications, you'd use an enumeration list so you can change the labels as many times as you want:



    const enum_options = [
    'enable',
    'disable',
    'hide',
    'show'
    ];
    // 3 is the index of the word 'show'
    toggleAction(data._id, 3, (err, data) => { // cool stuff }, false)


    That way the API never has to change when you change the labels to any word you desire. Which will also help alot if you ever have to support multiple languages.



    ps:



    1) if this is a breaking change, there's an issue with the architecture used.
    Fix the issues instead of adding even more fragile code. Switching to like using a string 'undelete-unhide' will still need alot of api changes if the entire app has the word 'undelete' written everywhere at the moment.



    2) The opposite of hide is usually 'show', not unhide.






    share|improve this answer




























      0














      Kinda opinion based, but it's the wrong approach imho.
      I would change the word undelete to unhide only on the rendered websites and keep the internal API the same way until the senior devs can fix the breaking changes.
      So the user would see the word 'unhide' on their screen, but the API will still stay 'undelete'.



      In more complex applications, you'd use an enumeration list so you can change the labels as many times as you want:



      const enum_options = [
      'enable',
      'disable',
      'hide',
      'show'
      ];
      // 3 is the index of the word 'show'
      toggleAction(data._id, 3, (err, data) => { // cool stuff }, false)


      That way the API never has to change when you change the labels to any word you desire. Which will also help alot if you ever have to support multiple languages.



      ps:



      1) if this is a breaking change, there's an issue with the architecture used.
      Fix the issues instead of adding even more fragile code. Switching to like using a string 'undelete-unhide' will still need alot of api changes if the entire app has the word 'undelete' written everywhere at the moment.



      2) The opposite of hide is usually 'show', not unhide.






      share|improve this answer


























        0












        0








        0







        Kinda opinion based, but it's the wrong approach imho.
        I would change the word undelete to unhide only on the rendered websites and keep the internal API the same way until the senior devs can fix the breaking changes.
        So the user would see the word 'unhide' on their screen, but the API will still stay 'undelete'.



        In more complex applications, you'd use an enumeration list so you can change the labels as many times as you want:



        const enum_options = [
        'enable',
        'disable',
        'hide',
        'show'
        ];
        // 3 is the index of the word 'show'
        toggleAction(data._id, 3, (err, data) => { // cool stuff }, false)


        That way the API never has to change when you change the labels to any word you desire. Which will also help alot if you ever have to support multiple languages.



        ps:



        1) if this is a breaking change, there's an issue with the architecture used.
        Fix the issues instead of adding even more fragile code. Switching to like using a string 'undelete-unhide' will still need alot of api changes if the entire app has the word 'undelete' written everywhere at the moment.



        2) The opposite of hide is usually 'show', not unhide.






        share|improve this answer













        Kinda opinion based, but it's the wrong approach imho.
        I would change the word undelete to unhide only on the rendered websites and keep the internal API the same way until the senior devs can fix the breaking changes.
        So the user would see the word 'unhide' on their screen, but the API will still stay 'undelete'.



        In more complex applications, you'd use an enumeration list so you can change the labels as many times as you want:



        const enum_options = [
        'enable',
        'disable',
        'hide',
        'show'
        ];
        // 3 is the index of the word 'show'
        toggleAction(data._id, 3, (err, data) => { // cool stuff }, false)


        That way the API never has to change when you change the labels to any word you desire. Which will also help alot if you ever have to support multiple languages.



        ps:



        1) if this is a breaking change, there's an issue with the architecture used.
        Fix the issues instead of adding even more fragile code. Switching to like using a string 'undelete-unhide' will still need alot of api changes if the entire app has the word 'undelete' written everywhere at the moment.



        2) The opposite of hide is usually 'show', not unhide.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 16:35









        ShillyShilly

        5,7181717




        5,7181717
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323783%2fkeep-sending-a-string-without-breaking-changes-on-this-npm-library%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine