Pages

Wednesday, May 18, 2011

Java Collection tip : Use the Java library - Don't write your own

Most data structure textbooks give students the impression that professional programmers implement basic data structures, such as linked lists, or write their own sort methods. This is completely false! Many standard data structures and algorithms have already been written and are available in Java. Professional programmers use these library classes as building blocks for their application specific structures. Textbooks give this distorted view because their emphasis is on understanding how data structures are build using only pointers/references and arrays. It's an excellent exercise and is necessary to becoming a good programmer. But textbooks often fail to emphasize the predefined data structure libraries that programmers actually use. You will, of course, often write data structures that reflect the nature of your problem, but use the library versions for the basic elements. And you will have plenty of opportunities to use this basic knowledge to to beyond the basics.

Productivity is much higher with the standard libraries

To be a productive programmer, your first choice must be to use standard library data structures. In Java this means using the Collection classes and interfaces.You will always have to write some of your own data structures, but you can program faster, and produce more robust and readable programs by building on the work of others.

Disclaimer

Java Jazzle is for learning and training only. Its not guaranteed that content published is correct. The risk from using it lies entirely with the user. Also the opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

About this blog

This is my tech blog. I write on this blog to save my searching stuff on google. It acts as my log of all the stuff I went through and saves my time, because I don't have to search again and again. Another reason for putting stuff on it was, when I am kind of free, it kind of kills it.