Link Details

Link 481089 thumbnail
User 754583 avatar

By justincater
Published: Sep 05 2010 / 00:08

Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to talk about String performance tunning. We will focus on how to handle String creation, String alteration and String matching operations efficiently. Furthermore we will provide our own implementations of the most commonly used algorithms for Exact String Matching. Many of these algorithms can achieve far more superior performance compared to the naive approach for exact String matching available with the Java Development Kit. This article concludes with a performance comparison between the aforementioned Exact String Matching algorithms.
  • 29
  • 1
  • 6345
  • 6


Add your comment
User 210175 avatar

jtheory replied ago:

0 votes Vote down Vote up Reply

Best practice for using strings in your application: make your code as *readable* as possible (and don't add in *extra* code to "optimize" your use of Strings) unless:
* you are writing code that will be processing enormous amounts of data as Strings
* you have determined via performance testing that the way you are using Strings is causing a performance hotspot.

I have seen a *lot* of Strings being optimized in a lot of Java code, and neither one of these criteria has been true in those cases thus far.

Please, please don't optimize (for example) your String concatenation while building SQL queries and so on. It's ridiculous, it's sadly ironic (er, what about optimizing that SQL query instead? You have far, far more to gain there), it uglifies your code and introduces bugs, and it's a dead giveaway that you're are a wannabe code guru (think of the wannabe racecar driver with a standard Ford Fiesta who adds on a massive spoiler and racing stripes).

Add your comment

Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Apache Hadoop
Written by: Piotr Krewski
Featured Refcardz: Top Refcardz:
  1. Play
  2. Akka
  3. Design Patterns
  4. OO JS
  5. Cont. Delivery
  1. Play
  2. Java Performance
  3. Akka
  4. REST
  5. Java