Addition/Deletion records based on method argument
Clash 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?
java
add a comment |Â
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?
java
2
soo ... what about booleans? Or an actually typesafe enum?
â Vogel612â¦
Apr 3 at 7:10
add a comment |Â
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?
java
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?
java
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
add a comment |Â
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
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered Apr 3 at 7:06
Imus
3,328223
3,328223
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
soo ... what about booleans? Or an actually typesafe enum?
â Vogel612â¦
Apr 3 at 7:10