Log

INFO |02 mag 2011 17:05:19| ZIdentityAsserter -  messageeeeeeeeeeeeeeee

Got it.

Found digging in a production logfile

Advertisements

With or without CRM

	var ccNoCRM=[
		 [0,-1,-1,-1,-1],
		 [1,1,1,0,0],
		 [2,1,1,0,0],
		 [3,1,1,0,0],
		 [4,1,1,0,0],
		 [5,0,0,0,0],
		 [6,0,0,0,0],
		 [7,0,0,0,0]
		];

	var ccYesCRM=[
		   [0,-1,-1,-1,-1],
		   [1,1,1,0,0],
		   [2,1,1,0,0],
		   [3,1,1,0,0],
		   [4,1,1,0,0],
		   [5,0,0,0,0],
		   [6,0,0,0,0],
		   [7,0,0,0,0]
		  ];

I think, it sunk my cruiser :/

Just found in the codebase of the big TLC Company


Max

	String InfoClientRS="\n[" +
		"\n[\"MAX15041967\",\""+IQ.getUnique_ID()+"\",\""+IQ.getTitle()+"\",\""+IQ.getName()+"\",\""
		+(CCOL==null?"":CCOL.replace('"', '\''))+"\",\""+IQ.implementFilter()+"\"];

Who is Max??

Actually in the codebase of the big TLC company, I guess (and hope) this code is unused


As promised

… in Condition, here the code contained by the if statement.

It’s a little bit convoluted, but it’s so well commented.

	/**/
	if (cod_tipo_uo.equals("21") || !cod_tipo_uo.equals("21")){
		if (itemComboTip.equals("")){
			ptfType = "";
			ptfSubTtypel = "";
			if (cod_tipo_uo.equals("A3")|| cod_tipo_uo.equals("94")){
				if (!ContextUtil.consumeArea(request, "CodItem").isEmpty() && 
						ContextUtil.consumeArea(request, "CodItem")!= null	){
					String val = (String) ContextUtil.consumeArea(request, "CodItem")
						.toArray() [0];
					val = val.substring(3,val.length());
					ContextUtil.informArea(request, val, "searchType");
	/***/ 
					if (!val.equals("ALL")){					
						ptfType = val.substring(0,2);
						if (val.length()== 5){
							ptfSubTtypel = val.substring(3,5);
						}else if (val.length()== 2){
							ptfSubTtypel = "";
						}	

						if (ptfSubTtypel.equals("")){
							ContextUtil.informArea(request,cod_tipo_uo 
								+'-'+ ptfType, "searchType");					
						}else ContextUtil.informArea(request,cod_tipo_uo 
							+'-'+ ptfType+'-'+ptfSubTtypel, "searchType");
					}				
	/****/							
				}	
			}else ContextUtil.informArea(request, "ALL", "searchType");
		}
	}

Still no clue of what it was about.

(I think) Actually in the production code of the Big Bank, I did not dare touch it


There’re not going to be…

… more than one thousand!

	var i;
	for (i = 0; i < 1000; i++){
		if (document.getElementById('row_' + i) != null){
			...
		}
	}

If you have to roll through a table, and you don’t know how many elements it has, choose an arbitrary high number and check for nulliness, all right.

In the codebase of the Big Bank


How to iterate

The problem is ‘remove a certain item from a collection’.
If you remove an object and the counter keep going, you’re going to jump the next element.

The solution my predecessor come to:

	private void removeData(String code){
		String sp914code;
			
		for (int i = 0; i < sp914Codes.size(); i++){
			sp914code = sp914Codes.get(i).toString();
			if(sp914code.equals(code)){
				sp914Codes.remove(i);
				i=-1;
			}
		}
	}

Restart everytime from the very beginning, obvious.

I doesn’t dare touch this, even if I’d worked on that class, in THAT Big Bank


Date parsing perversion /3

If you have to remove 15 days from a date, which way you’re going to take?

   	switch(endMonth) 
   	{
		case '01':
			startDay = startDay = 31 - (15 - endDay);
			startMonth = '12';
			startYear = endYear - 1;
			break;
		
		case '02':
			startDay = startDay = 31 - (15 - endDay);
			startMonth = '01';
			startYear = endYear;
			break;
			
		case '03':
			var isBisestile = startYear%4;
			var offset = (isBisestile == 0)? 29: 28;		
			
			startDay = offset - (15 - endDay);
			startMonth = '02';
			startYear = endYear;
			break;
			
		case '04':
			startDay = 31 - (15 - endDay);
			startMonth = '03';
			startYear = endYear;
			break;
			
		case '05':
			startDay = 30 - (15 - endDay);
			startMonth = '04';
			startYear = endYear;
			break;
			
		case '06':
			startDay = 31 - (15 - endDay);
			startMonth = '05';
			startYear = endYear;
			break;
			
		case '07':
			startDay = 30 - (15 - endDay);
			startMonth = '06';
			startYear = endYear;
			break;
			
		case '08':
			startDay = 31 - (15 - endDay);
			startMonth = '07';
			startYear = endYear;
			break;
			
		case '09':
			startDay = 31 - (15 - endDay);
			startMonth = '08';
			startYear = endYear;
			break;
			
		case '10':
			startDay = 30 - (15 - endDay);
			startMonth = '09';
			startYear = endYear;
			break;
			
		case '11':
			startDay = 31 - (15 - endDay);
			startMonth = '10';
			startYear = endYear;
			break;
			
		case '12':
			startDay = 30 - (15 - endDay);
			startMonth = '11';
			startYear = endYear;
			break;   				
    }

I hope not this one.

Many thanks to the Big Bank for providing me such gems