Rules and Tips for Good Web Programming (and Programming in General) Chengyu Sun California State University, Los Angeles
Follow naming conventions Use descriptive names Start with Data Java model classes and table schemas Use package Follow naming conventions Use descriptive names The different between primitive types vs class types
One servlet (i.e. controller) per operation Identify operations Display Add Rename Delete One servlet (i.e. controller) per operation One view per operation except for form processing operations, in which case we need two: one form view, one result view
JDBC driver only needs to loaded once per project; it has to be loaded before other servlets (use loadOnStartup) Use Id, do not use Name Use PreparedStatement it's safe, and more readable than string concatenation
Reuse code by refactoring them into their own classes/methods Pass data to JSP using Request Scope Do NOT use Application scope (i.e. getServletContext()) Avoid using Session scope for anything other than login/logout
Use SQL whenever possible Form processing operation Form view Result View After add a new folder Display the added folder Or Display the parent folder Redirect is a special view
Forward: pass data from controller to view Redirect: send the user to a different operation (controller) Use View Source Use the Debug feature in Eclipse