Addition/Deletion records based on method argument

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












I have one method for addition and deletion of the account records. It has method argument based on which addition or deletion happens.



Below is method



char ADD = 'Y';
char DELETE = 'N';
private void updateAccountDtls(AccountDtlsDTO accountDtlsDTO, char addOrDeleteRecord)
if (ADD == addOrDeleteRecord)
//account addition related processing

else if (DELETE == addOrDeleteRecord)
//account deletion related processing




which is consumed in switch like below



switch (action) 
case SET:
updateAccountDtls(accountDtlsDTO,ADD);
break;
case RESET:
updateAccountDtls(accountDtlsDTO,DELETE);
break;



from performace perspective is this good practice to use character instaed of string for Yes/No?







share|improve this question















  • 2




    soo ... what about booleans? Or an actually typesafe enum?
    – Vogel612♦
    Apr 3 at 7:10

















up vote
1
down vote

favorite












I have one method for addition and deletion of the account records. It has method argument based on which addition or deletion happens.



Below is method



char ADD = 'Y';
char DELETE = 'N';
private void updateAccountDtls(AccountDtlsDTO accountDtlsDTO, char addOrDeleteRecord)
if (ADD == addOrDeleteRecord)
//account addition related processing

else if (DELETE == addOrDeleteRecord)
//account deletion related processing




which is consumed in switch like below



switch (action) 
case SET:
updateAccountDtls(accountDtlsDTO,ADD);
break;
case RESET:
updateAccountDtls(accountDtlsDTO,DELETE);
break;



from performace perspective is this good practice to use character instaed of string for Yes/No?







share|improve this question















  • 2




    soo ... what about booleans? Or an actually typesafe enum?
    – Vogel612♦
    Apr 3 at 7:10













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have one method for addition and deletion of the account records. It has method argument based on which addition or deletion happens.



Below is method



char ADD = 'Y';
char DELETE = 'N';
private void updateAccountDtls(AccountDtlsDTO accountDtlsDTO, char addOrDeleteRecord)
if (ADD == addOrDeleteRecord)
//account addition related processing

else if (DELETE == addOrDeleteRecord)
//account deletion related processing




which is consumed in switch like below



switch (action) 
case SET:
updateAccountDtls(accountDtlsDTO,ADD);
break;
case RESET:
updateAccountDtls(accountDtlsDTO,DELETE);
break;



from performace perspective is this good practice to use character instaed of string for Yes/No?







share|improve this question











I have one method for addition and deletion of the account records. It has method argument based on which addition or deletion happens.



Below is method



char ADD = 'Y';
char DELETE = 'N';
private void updateAccountDtls(AccountDtlsDTO accountDtlsDTO, char addOrDeleteRecord)
if (ADD == addOrDeleteRecord)
//account addition related processing

else if (DELETE == addOrDeleteRecord)
//account deletion related processing




which is consumed in switch like below



switch (action) 
case SET:
updateAccountDtls(accountDtlsDTO,ADD);
break;
case RESET:
updateAccountDtls(accountDtlsDTO,DELETE);
break;



from performace perspective is this good practice to use character instaed of string for Yes/No?









share|improve this question










share|improve this question




share|improve this question









asked Apr 3 at 6:48









Sandeep Thaker

84




84







  • 2




    soo ... what about booleans? Or an actually typesafe enum?
    – Vogel612♦
    Apr 3 at 7:10













  • 2




    soo ... what about booleans? Or an actually typesafe enum?
    – Vogel612♦
    Apr 3 at 7:10








2




2




soo ... what about booleans? Or an actually typesafe enum?
– Vogel612♦
Apr 3 at 7:10





soo ... what about booleans? Or an actually typesafe enum?
– Vogel612♦
Apr 3 at 7:10











1 Answer
1






active

oldest

votes

















up vote
6
down vote



accepted










Performance wise you're not going to notice the difference.



There is a far better solution available to you though. That is to have 2 separate methods altogether.



You already have a switch statement before calling the method in which you know that it will be a delete or an add. This makes it really easy to just call the right method.



Having separate methods that each do a specific thing makes the code easier to read and maintain later on.






share|improve this answer





















    Your Answer




    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
    );
    );
    , "mathjax-editing");

    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: "196"
    ;
    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f191129%2faddition-deletion-records-based-on-method-argument%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote



    accepted










    Performance wise you're not going to notice the difference.



    There is a far better solution available to you though. That is to have 2 separate methods altogether.



    You already have a switch statement before calling the method in which you know that it will be a delete or an add. This makes it really easy to just call the right method.



    Having separate methods that each do a specific thing makes the code easier to read and maintain later on.






    share|improve this answer

























      up vote
      6
      down vote



      accepted










      Performance wise you're not going to notice the difference.



      There is a far better solution available to you though. That is to have 2 separate methods altogether.



      You already have a switch statement before calling the method in which you know that it will be a delete or an add. This makes it really easy to just call the right method.



      Having separate methods that each do a specific thing makes the code easier to read and maintain later on.






      share|improve this answer























        up vote
        6
        down vote



        accepted







        up vote
        6
        down vote



        accepted






        Performance wise you're not going to notice the difference.



        There is a far better solution available to you though. That is to have 2 separate methods altogether.



        You already have a switch statement before calling the method in which you know that it will be a delete or an add. This makes it really easy to just call the right method.



        Having separate methods that each do a specific thing makes the code easier to read and maintain later on.






        share|improve this answer













        Performance wise you're not going to notice the difference.



        There is a far better solution available to you though. That is to have 2 separate methods altogether.



        You already have a switch statement before calling the method in which you know that it will be a delete or an add. This makes it really easy to just call the right method.



        Having separate methods that each do a specific thing makes the code easier to read and maintain later on.







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Apr 3 at 7:06









        Imus

        3,328223




        3,328223






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f191129%2faddition-deletion-records-based-on-method-argument%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Chat program with C++ and SFML

            Function to Return a JSON Like Objects Using VBA Collections and Arrays

            Will my employers contract hold up in court?