
// This is a comment
August 11, 2006I recently ran across an blog entry concerning bad code examples. The gist of the article is that even when, nay, especially when, teaching we should use good coding technique. I thought it an excellent point.
Not long after, I ran across this JPA example code over on the GlassFish Project. The code is straightforward, but what caught my attention were the utterly superfluous comments. For example, this snippet under the “Using in J2SE” heading:
// Create EntityManagerFactory for persistent unit named
// "pu1" to be used in this test
emf = Persistence.createEntityManagerFactory("pu1");
How useful is the comment? Not very. Even worse:
// Begin transaction
em.getTransaction().begin();
Now, really, do we need to document self-documenting code?
Posted in Java Bar |