I tried searching for this question but had no luck. I'm sure this question must have been asked several times before.
The official libraries contain thousands of objects that could perform a specific function in a project instead of writing from scratch. But how does one find them? I doubt anyone is so familiar they just "know". How is this dealt with as the libraries continue to grow in size and scope? Are there any tools available? What do most people do if that is known?
Generally, I tend to remember what differrent libraries do, not individual classes. I might remember some important, most-used ones, but not all classes. So, I remember that apache-commons has a library for collections, another one has utilities for language support, another one implements a pool, and so on. Once, I need something, I look into the API docs for the most relevant library.
Or sometimes, just reading through the code of Open source projects helps. "I need to generate some java byte code during runtime. I know Spring generates proxies at runtime. I wonder how does spring do it?" Google and read through spring code for 2 hours "Oh Spring uses CGlib to generate proxies. Maybe I can use it too!"
Just don;t try to remember everything. Instead learn/remember things that help you in finding information.
Edit: SOmetimes learning the correct terminology also helps in finding stuff. No offense, but I'm sure if I call classes as objects, I would have hard time finding stuff.
posted 5 years ago
I got it. Classes are what objects are made from.
I find it surprising with all the libraries of classes that a search tool of some sort has not become a popular item with Java developers. I'm sure there are some items that are used frequently and developers learn about them as a matter of course. But eventually it will be necessary to have some way of plowing through the libraries to find if something already exists.
Most of the libraries are well documented. Indeed, documentation is one of the criteria for me for a good library.
Such documentation almost always includes How to/FAQ/Quick starter type of sections with relevant code examples. Once you get a feel of how to go about things, it is a matter of routine to check out the API. Many times class names will be self explanatory. e.g. DocumentParser. Reading the name tells you this would provide a document parsing ability.
If you google enough and/or hang out on forums trying to answer questions, you will always be rewarded with some gem of new information.
Sterling Crapser wrote:I find it surprising with all the libraries of classes that a search tool of some sort has not become a popular item with Java developers. I'm sure there are some items that are used frequently and developers learn about them as a matter of course. But eventually it will be necessary to have some way of plowing through the libraries to find if something already exists.
I don't think Java's alone there although, after humpteen years, it's libraries are likely bigger than most. My usual rule of thumb is that, like a writer, I assume that if something's useful, it's probably already been written (the writer's mantra is that if it sounds good, Shakespeare probably already wrote it ).
In many cases you'll have some idea where to start. For example, for a search, I'd probably start out with classes that make up the Java Collections Framework.
But that doesn't always hold true. For example, I almost always use "LinkedHash" classes (eg, LinkedHashMap) when I want a hashed structure now; but it took me about a year to discover them because they're not often mentioned in classes or tutorials.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here