Weitere ähnliche Inhalte Ähnlich wie Ugly code (20) Ugly code1.
yzheng@thoughtworks.com
10.
if (1 == insertFlag) { if (1 == insertFlag) {
retList.insert(i, newCatalog); retList.insert(m, newCatalog);
} else { } else {
retList.add(newCatalog); retList.add(newCatalog);
}! } !
if (1 == insertFlag) {
retList.insert(j, newPrivNode);
} else {
retList.add(newPrivNode);
}!
11.
if ( "" != *OPRNUMB) {
para.insert("OPRNUMB", OPRNUMB->getData());
}
if ( "" != *MSISDN) {
para.insert("TELNUM", MSISDN->getData());
}
if ( "" != *TMSISDN) {
para.insert("TMSISDN", TMSISDN->getData());
}!
13.
if ( strcmp(type, “DropGroup") == 0
|| strcmp(type, "CancelUserGroup") == 0
|| strcmp(type, "QFUserGroup") == 0
|| strcmp(type, "CancelQFUserGroup") == 0
|| strcmp(type, "QZUserGroup") == 0
|| strcmp(type, "CancelQZUserGroup") == 0
|| strcmp(type, "SQUserGroup") == 0
|| strcmp(type, "CancelSQUserGroup") == 0
|| strcmp(type, “UseGroup") == 0
|| strcmp(type, "CancelGroup") == 0)
15. if
if (0 == retCode) {
SendMsg("000", "Process Success", outResult);
} else {
SendMsg("000", "Process Failure", outResult);
}
const char* msg = (0 == retCode
? "Process Success"
: "Process Failure");
SendMsg("000", msg, outResult);
16. if(!strcmp(pRec->GetType(), RECTYPE::INSTALL)) {
CommDM.ChangGroupInfo(
const_cast(CommDM.GetAttr("IPAddress",
&(pGroup->m_Attr))),
true);
} else {
CommDM.ChangGroupInfo(
const_cast(CommDM.GetAttr("IPAddress",
&(pGroup->m_Attr))),
false);
}
18. switch(firstChar) {
case ‘N’:
nextFirstChar = ‘O’;
break;
case ‘O’:
switch(firstChar) {
nextFirstChar = ‘P’;
case ‘N’:
break;
case ‘O’:
case ‘P’:
case ‘P’:
nextFirstChar = ‘Q’;
case ‘Q’:
break;
case ‘R’:
case ‘Q’:
nextFirstChar = firstChar + 1;
nextFirstChar = ‘R’;
break;
break;
case ‘T’:
case ‘R’:
throw IllegalArgumentException();
nextFirstChar = ‘S’;
default:
break;
}!
case ‘S’:
nextFirstChar = ‘T’;
break;
case ‘T’:
throw IllegalArgumentException();
default:
}
19.
if (firstChar >= ‘N’ && firstChar <= ‘S”) {
nextFirstChar = firstChar + 1;
} else {
throw IllegalArgumentException();
}!
21.
void processService(const char *oprCode, const char *subID,
const char *oID, XList *callCicsList) {
Xstring relaPri(“NULL”);
Xstring relaSec(“NULL”);
Xstring scoutBySec(“0”);
XList *tempList = new Xlist;
callCicsList->add(tempList);
tempList->add(new XString(oprCode));
tempList->add(new XString(oID));
XString *psTelNum = new XString;
tempList->add(psTelNum);
GetServnumberBySubsID(subID, *psTelNum);
tempList->add(new CEntityString(esRelaPri.GetData()));
tempList->add(new CEntityString(esRelaSec.GetData()));
tempList->add(new CEntityString(esScoutBySec.GetData()));
}!
23.
ColdRule *newRule = new ColdRule();
newRule->SetOID(oldRule->GetOID());
newRule->SetRegion(oldRule->GetRegion());
newRule->SetRebateRuleID(oldRule->GetRebateRuleID());
newRule->SetBeginCycle(oldRule->GetBeginCycle() + 1);
newRule->SetEndCycle(oldRule->GetEndCycle());
newRule->SetMainAcctAmount(oldRule->GetMainAcctAmount());
newRule->SetGiftAcctAmount(oldRule->GetGiftAcctAmount());
newRule->SetValidDays(0);
newRule->SetGiftAcct(oldRule->GetGiftAcct());
rules->Add(newRule);
24.
ColdRule* CreateNewRule(ColdRule& oldRule) {
ColdRule *newRule = new ColdRule();
newRule->SetOID(oldRule.GetOID());
newRule->SetRegion(oldRule.GetRegion());
newRule->SetRebateRuleID(oldRule.GetRebateRuleID());
newRule->SetBeginCycle(oldRule.GetBeginCycle() + 1);
newRule->SetEndCycle(oldRule.GetEndCycle());
newRule->SetMainAcctAmount(oldRule.GetMainAcctAmount());
newRule->SetGiftAcctAmount(oldRule.GetGiftAcctAmount());
newRule->SetValidDays(0);
newRule->SetGiftAcct(oldRule.GetGiftAcct());
return newRule
}
rules->Add(CreateNewRule(*oldRule));
26. return bool
int RecComm::setIDBySevNum(const CEntityString& servnumber ) {
DB db;
db.setSQL("select id from users where servnumber=:servnumber");
db.bind(":servnumber", servnumber.c_str());
db.open();
if (!db.next()) {
return -1;
}
setID(db.getString(”id"));
return 0;
}!
27. reference
void Opcode::notifyCRM(const char * prodid,
const char * paramid,
CEntityString * retparam) {
if (NULL == prodid || NULL == paramid
|| NULL == retparam) {
throw IllegalArgumentsException (
Error::GetErrorMsg(”880022", "Opcode::notifyCRM"));
}
…
}!
30.
•
•
•
• if/while/for
•
•
•
31.
•
• Effective XX