Presentation is loading. Please wait.

Presentation is loading. Please wait.

Rules and Tips for Good Web Programming (and Programming in General)

Similar presentations


Presentation on theme: "Rules and Tips for Good Web Programming (and Programming in General)"— Presentation transcript:

1 Rules and Tips for Good Web Programming (and Programming in General)
Chengyu Sun California State University, Los Angeles

2 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

3 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

4 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

5 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

6 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

7 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


Download ppt "Rules and Tips for Good Web Programming (and Programming in General)"

Similar presentations


Ads by Google