Here's one example, based on actual code using JDBC:
long id = resultSet.getLong(resultSet.findColumn("ID"));
It would be better written as
long id = resultSet.getLong("ID");
but I'm guessing it was written the way it was based on copying something else.
I generally start by copying examples, but once I get a feel for what I'm doing, I'll look at the documentation or the source code. Often, I'll find that there are better ways of doing things if what I'm doing is not exactly what is done in the examples. That's one of the reasons the second and third and so on times I write something, I'll write it better than the first and second and so on time I wrote it.
No comments:
Post a Comment