Pearls of Wisdom for Web Developers
Monday, August 06, 2012 10:55 PM
Stored Procedures (Database)
- very important to make SURE the definitions are stored in the code repository
- make CERTAIN the stored definitions are updated!
- deleted stored procs should be removed from the stored definitions
- make sure the name of the stored procedure matches what is in the database AND the filename
- if ALL stored procedures can be stored at once (automatically), this is the easiest way to maintain it (if done automatically, disable comments that might contain timestamps; this will obscure actual changes).
- always good to keep a dump of the schema somewhere in the code repository
- whenever new releases are made, or major changes that are released to all developers, the schema file should be updated.
- make sure definitions for columns are proper (i.e. PostgreSQL can create columns of type "serial", but will dump the definition as integer)
- periodically rebuild from schema file to ensure it is accurate
- good to have tests or some other way to automatically create test data so loading from fresh schema doesn't encounter issues
- while it may seem like a good idea to store the entire database file in the code repository, it will usually end in frustration (except maybe file-based DB's like SQLite).
- show what is required immediately
- remember values if the form must be shown again due to errors
- highlight exactly what the problem is so they don't have to guess
- open links in a new window or popup so user doesn't lose work!
- validate on-the-fly (where appropriate) for expediency
- "forget" form values after successful submission (e.g. if they're in the session, remove them)
- log everything!
- don't worry about viewing the logs right away: as long as they're available and complete, their usefulness will become obvious later
- always make sure time is logged, so it is known when the event occurred (make sure server's time is up-to-date)
AJAX (in general)
- have some indication that something is being processed
- disable buttons when form is being processed
- ALWAYS have a notification system so user can see when something goes wrong.
- don't use it just to use it!
- every check should implicitly show if user is logged-in, and should be able to redirect them (or otherwise handle) if their session expired.
- fewer lines of code isn't always better
- obfuscated or hard to read
- skipped conditions
- more lines of code isn't always better
- unnecessary expansion (long, confusing if / elseif / else statements
- excessive line breaks
- more commits isn't always better than fewer
- frequent broken commits
- minor changes per commit (just to maximize # of commits, e.g. for better stats)
- fewer commits isn't always better than more...
- long-running/untested changes
- massive changes resulting in more bugs