Overview
The
enum in Java is more powerful than many other languages which can lead to surprising uses.
In this article, I outline some the individual features of
enum in Java, and put them together to form a state machine.
http://www.javacodegeeks.com/search/label/Java%20Best%20Practices
Java Secret: Using an enum to build a State machine
Friday, 8 July 2011
Low GC in Java: Use primitives instead of wrappers
Overview
There are two good reason to use primitives instead of wrappers where possible.
There are two good reason to use primitives instead of wrappers where possible.
- Clarity. By using a primitive, you are making it clear that a null value is not appropriate.
- Performance. Using primitives is often much faster.
Monday, 8 November 2010
Java Best Practices – Char to Byte and Byte to Char conversions
Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to talk about
String performance tunning. Especially we will focus on how to handle character to byte and byte to character conversions efficiently when the default encoding is used. This article concludes with a performance comparison between two proposed custom approaches and two classic ones (the "
String.getBytes()" and the
NIO
ByteBuffer) for converting characters to bytes and vice – versa.
Tuesday, 21 September 2010
Java Best Practices – Queue battle and the Linked ConcurrentHashMap
Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to perform a performance comparison between four popular
Queue implementation classes with relevant semantics. To make things more realistic we are going to test against a multi–threading environment so as to discuss and demonstrate how to utilize
ArrayBlockingQueue,
ConcurrentLinkedQueue,
LinkedBlockingQueue and/or
LinkedList for high performance applications.
Last but not least we are going to provide our own implementation of a ConcurrentHashMap. The ConcurrentLinkedHashMap implementation differs from ConcurrentHashMap in that it maintains a doubly–linked list running through all of its entries. This linked list defines the iteration ordering, which is normally the order in which keys were inserted into the map. The ConcurrentLinkedHashMap benefits from the combined characteristics of ConcurrentHashMap and LinkedHashMap achieving performance just slightly below that of ConcurrentHashMap due to the added expense of maintaining the linked list.
Last but not least we are going to provide our own implementation of a ConcurrentHashMap. The ConcurrentLinkedHashMap implementation differs from ConcurrentHashMap in that it maintains a doubly–linked list running through all of its entries. This linked list defines the iteration ordering, which is normally the order in which keys were inserted into the map. The ConcurrentLinkedHashMap benefits from the combined characteristics of ConcurrentHashMap and LinkedHashMap achieving performance just slightly below that of ConcurrentHashMap due to the added expense of maintaining the linked list.
Saturday, 4 September 2010
Java Best Practices – String performance and Exact String Matching
Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to talk about
String performance tuning. 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.
Monday, 16 August 2010
Java Best Practices – Vector vs ArrayList vs HashSet
Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to perform a performance comparison between the three probably most used
Collection implementation classes. To make things more realistic we are going to test against a multi–threading environment so as to discuss and demonstrate how to utilize
Vector,
ArrayList and/or
HashSet for high performance applications.
Friday, 23 July 2010
Java Best Practices – High performance Serialization
Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to discuss and demonstrate how to utilize Object Serialization for high performance applications.
Sunday, 11 July 2010
Java Best Practices – DateFormat in a Multithreading Environment
This is the first of a series of articles concerning proposed practices while working with the Java programming language.
All discussed topics are based on use cases derived from the development of mission critical, ultra high performance production systems for the telecommunication industry.
All discussed topics are based on use cases derived from the development of mission critical, ultra high performance production systems for the telecommunication industry.