Saturday, September 10, 2011

Important guidlines for Java Programming

1. Never directly modify code generated by JAXB.
2. Generate JAXB into separate packages-don't commingle
3. Don't use generated JAXB classes as value objects in applications.
4. Do not close connection objects or issue commits, rollbacks, or savepoints within a DAO.
5. Database objects created within a method should be closed within the same method.
6. Always pass the database connection from the business logic layer.
7. Always specify a column list with an insert statement.
8. Always speicfy a column list with a select statement.
9. Use host variables in SQL statemnets instead of hard-coding literals in SQL strings.
10. code test cases for all DAO methods and put them in the test suite.
11. Any method that creates a database connection should close it in a finally block.
12. All exceptions thrown should implement.
13. Using stateless session beans improve performance.
14. Stateless session beans should avoid instance-level variables.
15. MDB's should not throw exceptions.
16. Acknowledge message receipt in a finally block.
17. Using native JDK exceptions before creating your own.
18. Exploit Java's unchecked exception capability.
19. Use native JDK exceptions before creating your own.
20. Limit the nesting depth of a try/catch block to two.
21. Don't catch exceptions and do nothing with them.
22. Never put a return statement in a finally block.
23. Avoid explicitly setting thread priority.
24. Explicitly name all created threads.
25. Identify all threads as daemon threads.
26. Log enough information on error so that you can reproduce an error sutuation in a single-threaded test case.
27. Explicitly name all created threads.

No comments:

Post a Comment