Refactoring many nested ifs or chained if statements
Posted
by Icarus
on Stack Overflow
See other posts from Stack Overflow
or by Icarus
Published on 2010-03-27T15:39:06Z
Indexed on
2010/03/27
15:43 UTC
Read the original article
Hit count: 296
refactoring
Hi,
I have an object with large number of similar fields (like more than 10 of them) and I have to assign them values from an array of variable length. The solution would be either a huge nested bunch of ifs based on checking length of array each time and assigning each field
OR
a chain of ifs checking on whether the length is out of bounds and assigning each time after that check.
Both seem to be repetitive. Is there a better solution ?
© Stack Overflow or respective owner