SlideShare ist ein Scribd-Unternehmen logo
1 von 35
Downloaden Sie, um offline zu lesen


             	

yzheng@thoughtworks.com



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());
}

XString& servNumber;
XString domain;
db->getParameter(”domain", domain);

domain = servNumber + domain;




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);
}!



if ( "" != *OPRNUMB) {
    para.insert("OPRNUMB", OPRNUMB->getData());
}

if ( "" != *MSISDN) {
    para.insert("TELNUM", MSISDN->getData());
}

if ( "" != *TMSISDN) {
    para.insert("TMSISDN", TMSISDN->getData());
}!



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)


                                            	


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);
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);
}

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:
}



if (firstChar >= ‘N’ && firstChar <= ‘S”) {
    nextFirstChar = firstChar + 1;
} else {
    throw IllegalArgumentException();
}!


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()));	

}!



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);


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));

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;
}!
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"));
  }

  …
}!




	





                  	

      	




•                              	

•                        	

•                 	

•  if/while/for                      	

•                                                 	

•                                           	

•                  	



•    	

•           Effective XX   	

http://dreamhead.blogbus.com/tag/   /

http://www.infoq.com/cn/ugly-code




Weitere ähnliche Inhalte

Was ist angesagt?

Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in RustIngvar Stepanyan
 
Extreme JavaScript Performance
Extreme JavaScript PerformanceExtreme JavaScript Performance
Extreme JavaScript PerformanceThomas Fuchs
 
2² C# 4.0 and .NET 4 Selected Features
2² C# 4.0 and .NET 4 Selected Features2² C# 4.0 and .NET 4 Selected Features
2² C# 4.0 and .NET 4 Selected FeaturesMustafa Isik
 
The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 50 of 88
The Ring programming language version 1.3 book - Part 50 of 88The Ring programming language version 1.3 book - Part 50 of 88
The Ring programming language version 1.3 book - Part 50 of 88Mahmoud Samir Fayed
 
Numerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingNumerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingUtsav Patel
 
Code as data as code.
Code as data as code.Code as data as code.
Code as data as code.Mike Fogus
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good codeGiordano Scalzo
 
Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Baruch Sadogursky
 
The Ring programming language version 1.4 book - Part 18 of 30
The Ring programming language version 1.4 book - Part 18 of 30The Ring programming language version 1.4 book - Part 18 of 30
The Ring programming language version 1.4 book - Part 18 of 30Mahmoud Samir Fayed
 
The Macronomicon
The MacronomiconThe Macronomicon
The MacronomiconMike Fogus
 
Travel management
Travel managementTravel management
Travel management1Parimal2
 
The Ring programming language version 1.8 book - Part 30 of 202
The Ring programming language version 1.8 book - Part 30 of 202The Ring programming language version 1.8 book - Part 30 of 202
The Ring programming language version 1.8 book - Part 30 of 202Mahmoud Samir Fayed
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureMike Fogus
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treeraviahuja11
 
Goroutines and Channels in practice
Goroutines and Channels in practiceGoroutines and Channels in practice
Goroutines and Channels in practiceGuilherme Garnier
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. ExperienceMike Fogus
 
RxJS - 封裝程式的藝術
RxJS - 封裝程式的藝術RxJS - 封裝程式的藝術
RxJS - 封裝程式的藝術名辰 洪
 

Was ist angesagt? (20)

Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
 
Extreme JavaScript Performance
Extreme JavaScript PerformanceExtreme JavaScript Performance
Extreme JavaScript Performance
 
2² C# 4.0 and .NET 4 Selected Features
2² C# 4.0 and .NET 4 Selected Features2² C# 4.0 and .NET 4 Selected Features
2² C# 4.0 and .NET 4 Selected Features
 
3
33
3
 
The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184The Ring programming language version 1.5.3 book - Part 77 of 184
The Ring programming language version 1.5.3 book - Part 77 of 184
 
Promise is a Promise
Promise is a PromisePromise is a Promise
Promise is a Promise
 
The Ring programming language version 1.3 book - Part 50 of 88
The Ring programming language version 1.3 book - Part 50 of 88The Ring programming language version 1.3 book - Part 50 of 88
The Ring programming language version 1.3 book - Part 50 of 88
 
Numerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingNumerical Methods with Computer Programming
Numerical Methods with Computer Programming
 
Code as data as code.
Code as data as code.Code as data as code.
Code as data as code.
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
 
Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014
 
The Ring programming language version 1.4 book - Part 18 of 30
The Ring programming language version 1.4 book - Part 18 of 30The Ring programming language version 1.4 book - Part 18 of 30
The Ring programming language version 1.4 book - Part 18 of 30
 
The Macronomicon
The MacronomiconThe Macronomicon
The Macronomicon
 
Travel management
Travel managementTravel management
Travel management
 
The Ring programming language version 1.8 book - Part 30 of 202
The Ring programming language version 1.8 book - Part 30 of 202The Ring programming language version 1.8 book - Part 30 of 202
The Ring programming language version 1.8 book - Part 30 of 202
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of Clojure
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Goroutines and Channels in practice
Goroutines and Channels in practiceGoroutines and Channels in practice
Goroutines and Channels in practice
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. Experience
 
RxJS - 封裝程式的藝術
RxJS - 封裝程式的藝術RxJS - 封裝程式的藝術
RxJS - 封裝程式的藝術
 

Andere mochten auch

Paying council tax top task workshop for 'Better connected 2012'
Paying council tax top task workshop for 'Better connected 2012'Paying council tax top task workshop for 'Better connected 2012'
Paying council tax top task workshop for 'Better connected 2012'John Fox
 
CIM Digital Bootcamp - 2/2/12 - SEO
CIM Digital Bootcamp - 2/2/12 - SEOCIM Digital Bootcamp - 2/2/12 - SEO
CIM Digital Bootcamp - 2/2/12 - SEOjonwalkerseo
 
Conflict and Bullying Session for K-2 Students
Conflict and Bullying Session for K-2 StudentsConflict and Bullying Session for K-2 Students
Conflict and Bullying Session for K-2 StudentsRosetta Eun Ryong Lee
 
Is Your SharePoint Healthy - SharePoint Saturday The Conference
Is Your SharePoint Healthy - SharePoint Saturday The ConferenceIs Your SharePoint Healthy - SharePoint Saturday The Conference
Is Your SharePoint Healthy - SharePoint Saturday The ConferenceRichard Harbridge
 
Edu guru presentation
Edu guru presentationEdu guru presentation
Edu guru presentationJess Krywosa
 
Cloudsearch @ ex.fm
Cloudsearch @ ex.fmCloudsearch @ ex.fm
Cloudsearch @ ex.fm__lucas
 

Andere mochten auch (10)

Sm ii j12 final
Sm ii j12 finalSm ii j12 final
Sm ii j12 final
 
Paying council tax top task workshop for 'Better connected 2012'
Paying council tax top task workshop for 'Better connected 2012'Paying council tax top task workshop for 'Better connected 2012'
Paying council tax top task workshop for 'Better connected 2012'
 
CIM Digital Bootcamp - 2/2/12 - SEO
CIM Digital Bootcamp - 2/2/12 - SEOCIM Digital Bootcamp - 2/2/12 - SEO
CIM Digital Bootcamp - 2/2/12 - SEO
 
Conflict and Bullying Session for K-2 Students
Conflict and Bullying Session for K-2 StudentsConflict and Bullying Session for K-2 Students
Conflict and Bullying Session for K-2 Students
 
10years100years
10years100years10years100years
10years100years
 
Is Your SharePoint Healthy - SharePoint Saturday The Conference
Is Your SharePoint Healthy - SharePoint Saturday The ConferenceIs Your SharePoint Healthy - SharePoint Saturday The Conference
Is Your SharePoint Healthy - SharePoint Saturday The Conference
 
Social media summit
Social media summitSocial media summit
Social media summit
 
Edu guru presentation
Edu guru presentationEdu guru presentation
Edu guru presentation
 
Cloudsearch @ ex.fm
Cloudsearch @ ex.fmCloudsearch @ ex.fm
Cloudsearch @ ex.fm
 
Presentation launch edited
Presentation launch editedPresentation launch edited
Presentation launch edited
 

Ähnlich wie Ugly code

Implement the Queue ADT using array – based approach. Using C++ prog.pdf
Implement the Queue ADT using array – based approach. Using C++ prog.pdfImplement the Queue ADT using array – based approach. Using C++ prog.pdf
Implement the Queue ADT using array – based approach. Using C++ prog.pdfsktambifortune
 
Please teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdfPlease teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdfamarndsons
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...DevGAMM Conference
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdffantasiatheoutofthef
 
Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)ujihisa
 
How to not write a boring test in Golang
How to not write a boring test in GolangHow to not write a boring test in Golang
How to not write a boring test in GolangDan Tran
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17LogeekNightUkraine
 
The Ring programming language version 1.9 book - Part 37 of 210
The Ring programming language version 1.9 book - Part 37 of 210The Ring programming language version 1.9 book - Part 37 of 210
The Ring programming language version 1.9 book - Part 37 of 210Mahmoud Samir Fayed
 
Embracing the-power-of-refactor
Embracing the-power-of-refactorEmbracing the-power-of-refactor
Embracing the-power-of-refactorXiaojun REN
 
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfgalagirishp
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and PolynomialAroosa Rajput
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! aleks-f
 
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxcmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxgordienaysmythe
 
#include stdio.h #include stdlib.h #include unistd.h #in.pdf
#include stdio.h #include stdlib.h #include unistd.h #in.pdf#include stdio.h #include stdlib.h #include unistd.h #in.pdf
#include stdio.h #include stdlib.h #include unistd.h #in.pdfcontact34
 
C++ adt c++ implementations
C++   adt c++ implementationsC++   adt c++ implementations
C++ adt c++ implementationsRex Mwamba
 

Ähnlich wie Ugly code (20)

WOTC_Import
WOTC_ImportWOTC_Import
WOTC_Import
 
Google Guava
Google GuavaGoogle Guava
Google Guava
 
Implement the Queue ADT using array – based approach. Using C++ prog.pdf
Implement the Queue ADT using array – based approach. Using C++ prog.pdfImplement the Queue ADT using array – based approach. Using C++ prog.pdf
Implement the Queue ADT using array – based approach. Using C++ prog.pdf
 
Please teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdfPlease teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdf
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
 
Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)
 
How to not write a boring test in Golang
How to not write a boring test in GolangHow to not write a boring test in Golang
How to not write a boring test in Golang
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17
 
The Ring programming language version 1.9 book - Part 37 of 210
The Ring programming language version 1.9 book - Part 37 of 210The Ring programming language version 1.9 book - Part 37 of 210
The Ring programming language version 1.9 book - Part 37 of 210
 
Embracing the-power-of-refactor
Embracing the-power-of-refactorEmbracing the-power-of-refactor
Embracing the-power-of-refactor
 
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! 
 
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxcmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
 
#include stdio.h #include stdlib.h #include unistd.h #in.pdf
#include stdio.h #include stdlib.h #include unistd.h #in.pdf#include stdio.h #include stdlib.h #include unistd.h #in.pdf
#include stdio.h #include stdlib.h #include unistd.h #in.pdf
 
C++ adt c++ implementations
C++   adt c++ implementationsC++   adt c++ implementations
C++ adt c++ implementations
 

Mehr von Odd-e

Business caseforagile agiletourbeijing
Business caseforagile agiletourbeijingBusiness caseforagile agiletourbeijing
Business caseforagile agiletourbeijingOdd-e
 
打造真正的软件
打造真正的软件打造真正的软件
打造真正的软件Odd-e
 
培育软件的可测试性
培育软件的可测试性培育软件的可测试性
培育软件的可测试性Odd-e
 
做一个对产品负责的PO
做一个对产品负责的PO做一个对产品负责的PO
做一个对产品负责的POOdd-e
 
庖丁解牛用户故事 (Splitting Your User Story)
庖丁解牛用户故事 (Splitting Your User Story)庖丁解牛用户故事 (Splitting Your User Story)
庖丁解牛用户故事 (Splitting Your User Story)Odd-e
 
Simplicity (简洁的艺术)
Simplicity (简洁的艺术)Simplicity (简洁的艺术)
Simplicity (简洁的艺术)Odd-e
 
鱼与熊掌 - 软件质量 vs 交付速度
鱼与熊掌 - 软件质量 vs 交付速度鱼与熊掌 - 软件质量 vs 交付速度
鱼与熊掌 - 软件质量 vs 交付速度Odd-e
 
Find your mirror
Find your mirror Find your mirror
Find your mirror Odd-e
 
敏捷教练如何运用欣赏式探询(AI)
敏捷教练如何运用欣赏式探询(AI)敏捷教练如何运用欣赏式探询(AI)
敏捷教练如何运用欣赏式探询(AI)Odd-e
 
敏捷 - 领导力的救赎
敏捷 - 领导力的救赎敏捷 - 领导力的救赎
敏捷 - 领导力的救赎Odd-e
 
Taking the business along for a ride
Taking the business along for a rideTaking the business along for a ride
Taking the business along for a rideOdd-e
 
分布式设计团队的敏捷之道
分布式设计团队的敏捷之道分布式设计团队的敏捷之道
分布式设计团队的敏捷之道Odd-e
 
Scrum敏捷实施实例讲解 out_softingtemplate.ppt_
 Scrum敏捷实施实例讲解 out_softingtemplate.ppt_ Scrum敏捷实施实例讲解 out_softingtemplate.ppt_
Scrum敏捷实施实例讲解 out_softingtemplate.ppt_Odd-e
 
Terry yin adding unit-test_to_legacy_code
Terry yin   adding unit-test_to_legacy_codeTerry yin   adding unit-test_to_legacy_code
Terry yin adding unit-test_to_legacy_codeOdd-e
 
张克强 敏捷的过程能力
张克强   敏捷的过程能力张克强   敏捷的过程能力
张克强 敏捷的过程能力Odd-e
 
杨根兴 软件过程改进与敏捷方法
杨根兴   软件过程改进与敏捷方法杨根兴   软件过程改进与敏捷方法
杨根兴 软件过程改进与敏捷方法Odd-e
 
阳陆育 大型软件产品的敏捷案例分享
阳陆育 大型软件产品的敏捷案例分享阳陆育 大型软件产品的敏捷案例分享
阳陆育 大型软件产品的敏捷案例分享Odd-e
 
Mike 关于敏捷的一些误解
Mike   关于敏捷的一些误解Mike   关于敏捷的一些误解
Mike 关于敏捷的一些误解Odd-e
 
Ethan huang 全民qa
Ethan huang   全民qaEthan huang   全民qa
Ethan huang 全民qaOdd-e
 
Li kai roll-out scrum in an intel organization
Li kai   roll-out scrum in an intel organizationLi kai   roll-out scrum in an intel organization
Li kai roll-out scrum in an intel organizationOdd-e
 

Mehr von Odd-e (20)

Business caseforagile agiletourbeijing
Business caseforagile agiletourbeijingBusiness caseforagile agiletourbeijing
Business caseforagile agiletourbeijing
 
打造真正的软件
打造真正的软件打造真正的软件
打造真正的软件
 
培育软件的可测试性
培育软件的可测试性培育软件的可测试性
培育软件的可测试性
 
做一个对产品负责的PO
做一个对产品负责的PO做一个对产品负责的PO
做一个对产品负责的PO
 
庖丁解牛用户故事 (Splitting Your User Story)
庖丁解牛用户故事 (Splitting Your User Story)庖丁解牛用户故事 (Splitting Your User Story)
庖丁解牛用户故事 (Splitting Your User Story)
 
Simplicity (简洁的艺术)
Simplicity (简洁的艺术)Simplicity (简洁的艺术)
Simplicity (简洁的艺术)
 
鱼与熊掌 - 软件质量 vs 交付速度
鱼与熊掌 - 软件质量 vs 交付速度鱼与熊掌 - 软件质量 vs 交付速度
鱼与熊掌 - 软件质量 vs 交付速度
 
Find your mirror
Find your mirror Find your mirror
Find your mirror
 
敏捷教练如何运用欣赏式探询(AI)
敏捷教练如何运用欣赏式探询(AI)敏捷教练如何运用欣赏式探询(AI)
敏捷教练如何运用欣赏式探询(AI)
 
敏捷 - 领导力的救赎
敏捷 - 领导力的救赎敏捷 - 领导力的救赎
敏捷 - 领导力的救赎
 
Taking the business along for a ride
Taking the business along for a rideTaking the business along for a ride
Taking the business along for a ride
 
分布式设计团队的敏捷之道
分布式设计团队的敏捷之道分布式设计团队的敏捷之道
分布式设计团队的敏捷之道
 
Scrum敏捷实施实例讲解 out_softingtemplate.ppt_
 Scrum敏捷实施实例讲解 out_softingtemplate.ppt_ Scrum敏捷实施实例讲解 out_softingtemplate.ppt_
Scrum敏捷实施实例讲解 out_softingtemplate.ppt_
 
Terry yin adding unit-test_to_legacy_code
Terry yin   adding unit-test_to_legacy_codeTerry yin   adding unit-test_to_legacy_code
Terry yin adding unit-test_to_legacy_code
 
张克强 敏捷的过程能力
张克强   敏捷的过程能力张克强   敏捷的过程能力
张克强 敏捷的过程能力
 
杨根兴 软件过程改进与敏捷方法
杨根兴   软件过程改进与敏捷方法杨根兴   软件过程改进与敏捷方法
杨根兴 软件过程改进与敏捷方法
 
阳陆育 大型软件产品的敏捷案例分享
阳陆育 大型软件产品的敏捷案例分享阳陆育 大型软件产品的敏捷案例分享
阳陆育 大型软件产品的敏捷案例分享
 
Mike 关于敏捷的一些误解
Mike   关于敏捷的一些误解Mike   关于敏捷的一些误解
Mike 关于敏捷的一些误解
 
Ethan huang 全民qa
Ethan huang   全民qaEthan huang   全民qa
Ethan huang 全民qa
 
Li kai roll-out scrum in an intel organization
Li kai   roll-out scrum in an intel organizationLi kai   roll-out scrum in an intel organization
Li kai roll-out scrum in an intel organization
 

Ugly code

  • 1.   yzheng@thoughtworks.com
  • 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. 
  • 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 <= ‘S”) { nextFirstChar = firstChar + 1; } else { throw IllegalArgumentException(); }!
  • 20. 
  • 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()));  }!
  • 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 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")); } … }!
  • 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.