Good programming practices

Archive for October, 2011

Simple SGML parser

October 30th, 2011

There exists many parsing libraries for XML, HTML and SGML. Sometimes it’s enough to use simple solution instead of whole library. I created 4 classes for parsing string into list of markups and plain text. The parser use regular expressions for extracting all elements. More…

Iterating over non null elements only

October 27th, 2011

Since Java 5 in this language exists very useful “foreach” statement. But if collection contains null elements, iterator will also return null. If code doesn’t check against null, this may cause a NullPointerException. So I made a simple class based on Decorator Design Pattern. It just wraps an Iterable or Iterator and return only non null values. More…

Barcode printing with GLE

October 4th, 2011

GLE (Graphics Layout Engine) is an Open Source project and a graphics script language for generating vector graphics. I used it for printing labels which contain some information about a products including barcode. Generated EPS files (PostScript) are easy to print, especially when you want to automate the process. More…