I have a piece of code where I iterate a map, till a certain condition is true and then later on use that condition to do some more stuff.
Example:
Map<BigInteger,List<String>> map = handler.getMap(); if(map!=null && !map.isEmpty()){ for (Map.Entry<BigInteger, List<String>> entry : map.entrySet()) { fillUpList(); if(list.size() > limit){ limitFlag = true; break; } } }else{ logger.info("\n>>>>> \n\t 6.1 NO enteries to iterate over (for given FC and target) \n"); } if(!limitFlag){ //continue only if limitFlag is not set // Do something }
I feel setting a flag and then using that to so more stuff is a code smell.
Am i right ? How shall I remove this ?