Home Casestudy Phone Number Recognizer refactoring

Phone Number Recognizer refactoring

Our customer, a worldwide leader in VoIP communication, needed to improve the performance of their phone number recognizer (PNR) tool.

The first phase of the project was to perform an analysis of the existing code and prepare a detailed report on the results. The challenge was to identify and locate bottlenecks and problems in the code impacting the tool performance and stability.

 

After completion of the analysis, the customer asked us to refactor the code.

 

Main tasks of code refactoring were:

  1. Increasing application performance and stability. Increasing quantity of numbers found and quality of recognition (better phone number attributes recognition – land line, fax, mobile number).
  2. Code porting to Mac OS X and Linux

 

Additional requirements:

  1. Size of compiled code should not significantly increase.
  2. Quality of search should be high. At least same quantity of numbers found required and no additional recognition errors introduced.

Softage consultants developed a project plan for code refactoring and completed the project to the customer's satisfaction.

 

As a result, the new version of the PNR tool performs 12 times better than the previous one:
1. The tool find more telephone numbers
2. The tool works faster
3. Code size is reduced

4. The tool became cross-platform (Windows, Mac OS X, Linux)


Project details:

Performance improvement

We used several methods to increase performance of the PNR tool, here are some examples:

1) Removed excessive copying of objects
Where possible constant references are used instead of making object copy, in most cases copy constructors and assignment operators were made private to avoid unexpected object copy.

2) Avoid double calculation of same value
Where possible store pre-calculated value in temporary variable or private class member to avoid calculating it several times. Most common examples here are loop border condition and constant array sizes.

3) Algorithmic optimization
Some linear searches were replaced with binary searches on ordered arrays or on tree-like structures


Stability improvement

To improve application stability the following things were done:

1) Exception handling
All external interface function implementations were enclosed by try-catch blocks to avoid any internal exceptions to go out from PNR code.

2) Control and minimize dynamic memory usage
Where it is possible dynamic memory usage was removed. Where its usage is required then more efforts were done to control dynamic memory better and avoid leaks.

3) Object life-time control
Every object now has an owner and controlled lifetime. When object can be used in many places and it is impossible to have single owner, reference counters are used to control object lifetime.

4) “Black-box” concept
In PNR implementation, all class members were made private, allowing only operations via class methods to disallow all “unwanted” class member changes from other parts of PNR.

5) Synchronization
Thread synchronizations were added to avoid changing objects from several threads at the same time.

 

Testimonial

 

“Softage has proven themselves a professional development partner that I feel confident in working with. During the year I have been working with them they have delivered projects on time and with good results. In addition to that, they have been communicative and reliable, qualities which we deem essential in our daily work.
I am happy to recommend Softage and look forward to working with them in the future!”

Peter Kalmstrom, Program Manager Skype Toolbars