Here is the peace of code, Which I am looking to make it more efficient
I see lots of if else statements,
Can any one help me to make it simple and reduce the number of lines of code
if(mmPageCounter.equalsIgnoreCase("trueNotFull")){
if(whatPageNext.equalsIgnoreCase("first"))
accountListSize = 5;
else
accountListSize = acctIdList.size();
}else if(mmPageCounter.equalsIgnoreCase("true")){
if(whatPageNext.equalsIgnoreCase("first"))
accountListSize = 5;
else
accountListSize = 10;
}else if(mmPageCounter.equalsIgnoreCase("false")){
if(whatPageNext.equalsIgnoreCase("alwaysFirst"))
accountListSize = acctIdList.size();
}
In the above code based on the mmPageCounter based on the value I am setting the
index of the For loop either to the full capactiy, or to the actual value
Full capacity means, The for loop will iterate only 10 items
ps : I have got the code working and its fine, But i am looking only for the fine tuning
If any one one has any fine tuning tips please share the links.
This does not make it faster but reduces code, you can substitute:
by:
and:
by:
UPDATE:
If mmPageCounter can only be “trueNotNull”, “true”, or “false” then I think this code is equivalent:
but you should write tests against current code and check that this code behaves exactly in the same way on edge cases.