Pit father Codes | + conditional loop, nested layers up to you?

for loops and if conditional statement, it is essential. But have you seen the most nested loops and conditional have several layers of it? Or, how many layers of nested up to you tolerate it?

â ???? IFA ???? ç ???? to ?? ¾ç ???? æ ???? C'¢ ç »?? æ ????

We take a look at the extreme pit father bar code:

// 这个无限循环嵌套,只是总循环的一部分。。。我已经绕晕在黄桷湾立交
if (recordList.size() > start) {
    for (int i = start; i < end; i++) {
        Map<String, Object> map = recordList.get(i);
        Map<String, Object> field11 = (Map<String, Object>) map.get("field"); //name -> code
        Map<String, Object> record11 = (Map<String, Object>) map.get("record"); // code -> value
        String catagory1 = map.get("categoryId").toString();
        //  查询第一种类型对应的其他类型
        SalaryDataVo ss = JSON.parseObject(JSON.toJSONString(map), SalaryDataVo.class);
        Page page3 = salaryManagerService.getAllRecordsByCondition(ss);
        if (page3.getRecords().size() > 0) {
            List<Map<String, Object>> salaryDataVos = page3.getRecords();
            salaryDataVos = this.reSetMap(salaryDataVos,null,null);
            for (Map<String, Object> map2 : salaryDataVos) {
                Map<String, Object> field2 = (Map<String, Object>) map2.get("field");
                Map<String, Object> record2 = (Map<String, Object>) map2.get("record");
                String catagory2 = map2.get("categoryId").toString();
                List<SalaryGroupVO> groupList2 = salaryGroupService.getSalaryGroupsItems(this.getUserCorpId(), catagory2);
                for (SalaryGroupVO cc : groupList2) {
                    cc.setCode(cc.getParentId() + cc.getCode());
                }
                //计算
                for (Map.Entry<String, Object> entity : field2.entrySet()) {
                    String keyName = entity.getKey();
                    for (SalaryGroupVO s2 : groupList2) {
                        if ("bigDecimal".equals(s2.getItemType()) && s2.getCode().equals(field2.get(keyName).toString()) && ("部门" != keyName) && ("姓名" != keyName) && StringUtils.isNotEmpty(s2.getItemType())) {
                            if (field11.containsKey(keyName)) {
                                if (field11.containsKey(keyName)) {
                                    String code1 = field11.get(keyName).toString();
                                    Double newValue = 0.0;
                                    Double oldValue=0.0;
                                    if (!record11.get(code1).toString().matches("^[0-9]*$")) {
                                        oldValue = Double.parseDouble(record11.get(code1).toString());
                                        if (record2.containsKey(entity.getValue().toString()) && (!record2.get(entity.getValue().toString()).toString().matches("^[0-9]*$"))) {
                                            String value2 = record2.get(entity.getValue().toString()).toString();
                                            newValue = Double.parseDouble(value2);
                                        }
                                        record11.remove(field11.get(keyName).toString());
                                    }

I counted a total of 11 layers of nested! ! !

Tucao Tucao go, this code logic there any good way to reconstruct it?

The following link to the comment, to collect their prizes:

https://gitee.com/oschina/bullshit-codes/blob/master/java/InfiniteCycle

6 anniversary of the code cloud, We are seeking a variety of pit father of code, a lot of prizes waiting for you to come and collect

See detailed participatory approach   https://gitee.com/oschina/bullshit-codes

Guess you like

Origin www.oschina.net/news/107151/nesting-bad-code