Popular Posts

Friday, June 12, 2015

Rules of Coding

Rules of Coding


  1. The most important language you will ever code in:  English (or the common spoken language used in your company).  -- So that everyone understands what you wrote and why.
  2. Never use a regular expression without saying in plain English what it is doing.  Regex is so hard to understand!!!  Example: what the heck is this doing.  Found in the gruntfile.js of bootstrap at https://github.com/twbs/bootstrap/blob/master/Gruntfile.js                                                          return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
  3. If you are going to modify something extensively, you are better off writing a new one and swapping it in when it is ready to go live.  For example, if you are extensivley modifying an email template that is currently being used in production, just make a new template with a creative name and use that, so you don't possibly mess up code that is still using the old template.   --This way you can also keep a clean backup of the old template and be able to rollback quickly.
  4. No one cares.  No matter how much you think a given coding principle is important, there is nothing worse than alienating your fellow co-workers by sticking to a principle.  It may still be important, but no one cares in the end.  Try living without it for a day and you'll find you are still alive.
  5. Don't bother committing code if you haven't tested it.  There are runtime errors and compile time errors.  So even if your code builds, it doesn't mean it's even going to work.  This will save you time in the end, believe me.  You will end up having to change your code that doesn't work, or rollback a feature that you comitted and later find out will never work (e.g. I added logic to update the CreatedDate of some table in the database, and come to find out you can't update a database autopopulated field.  So I get to rollback the "addition" I made across 5 files).

No comments: