Hi
I am wondering is there any better way to design loops. AS you see function1 and function2 has almost similar code expect getting Hash Map.
*Current Code 1 *
//Field
ResultSet rs = null;
HashMap<Object, Object> hashMap1;
HashMap<Object, Object> hashMap2;
if(somecondition)
{
function1()
}
else
{
function2();
}
void function1()
{
while(rs.next)
{
hashMap1 = someClass.getData1();
hashMap2 = someClass.getData2();
// compareHashMap
}
}
void function2()
{
while(rs.next)
{
hashMap1 = someClass.getModfiedData1();
hashMap2 = someClass.getModfiedData2();
// compareHashMap
}
}
Another Way( short and sweet) 2
while(rs.next)
{
if(somecondition)
{
hashMap1 = someClass.getData1();
hashMap2 = someClass.getData2();
}
else
{
hashMap1 = someClass.getModfiedData1();
hashMap2 = someClass.getModfiedData2();
}
// compareHashMap
}
Questions:
If there are 10000 records or more in DB is it better to go with 1 ?
Is there any alternate desgin or I go wiht No 2?
Thanks