The ZXing Coding StyleThe ZXing project mostly adheres to Java coding style, with a few changes: - 2 space indentation, no tabs
- 100 column limit
To be compatible with J2ME, everything in the core library must be written to Java 1.2. Please use Javadoc-style comments on all public methods. ConventionsIn addition, we have some requirements to make it easier for authors to understand each other's code. 2D coordinatesPlease observe the following: - All 2D arrays should be row-major, with the origin at the top-left corner.
- All methods which pass a coordinate should use column, row order, using the variables x, y.
- All methods which pass dimensions should use width, height as arguments, in that order.
- All methods which pass a rectangle should use left, top, width, height as arguments, in that order.
- Prefer variables like left and right rather than minX and maxX.
- When traversing a 2D array, please always use this as a template:
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
bitmap.get(x, y);
}
}Do not use i and j as loop counters or method parameters when dealing with images. PerformanceBecause ZXing is primarily targeted at mobile applications: - Avoid floating point operations.
- Try to limit the amount of memory used, for example using byte instead of int when possible.
- Try to reduce the number of objects you allocate, as garbage collection may be very slow.
- Remember that function calls are expensive. Try not to make a call per pixel unless you can get ProGuard to inline it.
|