HACKER Q&A
📣 revskill

Please share your programming wisdoms


From the amateur to the master, please share your wisdom that works best for you ? Please also list the context for the wisdoms as i know these things are contextual.


  👤 jjgreen Accepted Answer ✓
Beware a programming language which uses camel-case variables.

👤 chiefalchemist

👤 ajuc
I'm no master, but I figured out a few things:

1. check git blame in the place where you do changes before you do them - on several occassions I found out that the "obvious bug" I was fixing was introduced on purpose 2 years ago and the jira referenced in git commit explained why

2. don't refactor long pure methods into classes with many small methods - if you can refactor a method into smaller methods - that's fine, but if you need to introduce a class with internal state because of interactions between these small methods - DON'T. You give the caller the opportunity for many interesting bugs, race conditions etc.

3. when changing code look a few levels up and down the callstack and check if there are steps that are now redundant

4. it's much better to pass empty collection than null or optional

5. when you're testing conditional code - test the negative. For example when you add paging - don't only test that page 2 shows items from page 2 - also test that it doesn't show items from page 1


👤 DamonHD
Do not assume that times, dates or names are easy!

👤 throwaway798214
Not mine originally but "always check your inputs"