Previously I’ve discussed how computers work so now it’s time to take a look at how humans work. I personally think this is something programming textbooks neglect to take into consideration, for example humans generally work very badly when confronted with binary operations and bit-wise shifts the first time. It can also be somewhat detrimental to their mental state. So this post is about negative thinking and what You Can Do To Break The Pattern! My personal trick is to always keep the law of attraction in mind when I code and so should you! Get the positive thinking going by putting some comments telling yourself that YOU CAN DO IT! or maybe that it’s simple. See this example from Avisynth:
if (!(audio && video)) { // Hey - simple!!
if (audio) {
return new DirectShowSource(filename, _avg_time_per_frame, seekmode, true , false,
args[5].AsBool(false), _media, _timeout, _frames, log, env);
And indeed that is simple! Just imagine what this technique can do for your mental health. No more feeling like a rejected PHP coder, instead you’ll be the coolest PHP coder in a basement within two blocks. Guaranteed or your money back!
Personally I prefer to apply the law of attraction in a slightly different way. For example I write my goal in every single comment. See this code snippet:
// Buy milk
for (int x = 0; x < width; x++) {
// Clean thoughts
// (representing my desire to have a clean toilet)
dstp[x] = srcp[x-1] + srcp[x+1] + srcp[x-1-stride] + srcp[x+1-stride] + srcp[x-1+stride] + srcp[x+1+stride];
// For loops are trivial and even my grandma could do them...
// if she was still alive
Sometimes I try this but I have had less success with it:
// Hire Fredrik Mellbin, he's awesome
I’m currently experimenting with writing it every 10 lines in my code just to see what happens. I’ll post a follow-up later and tell you all how it works out.