+ All Categories
Home > Documents > Ugly code

Ugly code

Date post: 22-Jan-2015
Category:
Upload: agiletourchina
View: 650 times
Download: 1 times
Share this document with a friend
Description:
 
Popular Tags:
35
代码之丑 郑晔 [email protected]
Transcript

2. 3. 4. 5. char* servNumber;XString domain;db->getParameter(domain", domain);if (0 == strcmp(domain.getData(), "")) {domain.setData(servNumber);} else {XString tmpValue;XString tmpServnumber;tmpServnumber.setData(servNumber);tmpValue = tmpServnumber + domain;domain.setData(tmpValue.getData());} 6. 7. XString& servNumber;XString domain;db->getParameter(domain", domain);domain = servNumber + domain; 8. 9. 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());}! 12. 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) 14. 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);} 17. 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 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()));}! 22. 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)); 25. 26. return boolint 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"));}}! 28. 29. 30. if/while/for 31. Effective XX 32. http://dreamhead.blogbus.com/tag/ /http://www.infoq.com/cn/ugly-code 33. 34. 35.


Recommended