12

I am a hobbyist programmer and a beginner. Most of the time, I cannot solve the problem while sitting in front of the computer. For example, I was trying to find out if one number is a power of another. I couldn't figure out the solution until I grabbed a pen and a paper then analyzed the problem. In roughly 3 minutes I solved it and wrote the script in Python.

Sometimes I can solve the problem while sitting in front of a computer, but with some struggle. Is that ok?

9
  • 6
    To me this isn't too bad of an issue, and in fact plenty of people stare at the computer too much, eventually not realizing they have this issue to a lesser extent. Lots of professional programming is going to involve very rote changes instead of the tricky logical formulas usually given as homework assignments, and it's not so much of an issue if you can at least accomplish those.
    – Katana314
    Mar 11, 2016 at 22:25
  • 2
    I think you might just want to reword your question so that it makes more sense about programming.
    – Snoop
    Mar 11, 2016 at 22:30
  • 8
    This is completely subjective. Everyone learns and works differently. Do what works for you.
    – user22815
    Mar 11, 2016 at 22:32
  • 7
    In front of the computer can be the worst place to try to solve a problem, because you get too tempted to start typing when you should be thinking. Often getting way from the machine is better because it forces you to think not act. Most of my most difficult problems have been solved walking to the office in the morning. Mar 11, 2016 at 22:50
  • 2
    Also there's the question of just how difficult the problem is. As you gain more experience, some problems that are difficult now will become easy. But that just means that you get to solve even more difficult ones. For myself, I solve a lot of my really difficult ones while hiking or cross-country skiing.
    – jamesqf
    Mar 12, 2016 at 3:31

3 Answers 3

33

I tend to solve my most difficult problems:

  • In front of a whiteboard (sometimes without even drawing anything - just thinking about how to visualize a problem can sometimes lead to a solution)
  • While explaining them to colleagues
  • Looking out of the window
  • While taking a walk
  • Under the shower
  • On the toilet

Going away from the monitor is often very helpful for concentrating on the problem itself and not just on typing out an implementation.

The problem solving happens in your head. Typing in the program code is just how you explain your solution to the computer.

9
  • 1
    Thank you! You are right, the more I am away from a computer, the more I can focus on the problem. Mar 11, 2016 at 22:49
  • 3
    I remember reading a book (can't remember which, unfortunately) that suggested keeping a rubber duck at your desk, and when you are stumped, describe the problem out loud to the rubber duck. Mar 11, 2016 at 23:24
  • 8
    @StevenBurnap This is called rubber duck debugging and you likely read about it in The Pragmatic Programmer by Addison Wesley.
    – Philipp
    Mar 11, 2016 at 23:45
  • 3
    "Typing in the program code is just how you explain your solution to the computer." – Alan Perlis said: "Programs should be written for humans to read and only incidentally for machines to execute." I would rather look at this way: typing in the code is just how you explain your solution to your colleagues. The fact that once you describe the solution un-ambiguously in such a way that any human (including yourself, 6 months from now) can understand it, it also becomes executable by a machine, is just a side-effect of it being described rigorously enough that there are no ambiguities. … Mar 12, 2016 at 1:00
  • 5
    Re: rubber ducking. There's also a similar story with a teddy bear. Tutors at MIT used to sit teddy bears outside their offices. You were only allowed to knock after having explained your problem to the bear. Half of the students never knocked on the door, having figured out their problem while explaining it to the bear. Formulating a well-written, well-researched, well-formatted, detailed, high-quality question on StackExchange can have the same effect, which is (one of the reasons) why we're so anal about doing just that! Mar 12, 2016 at 1:19
7

I think that this is a good question. From how I interpret this, what I think you are asking is, "Is it okay that I periodically have to step away from the computer"?

I do not think that there is a day that goes by where I don't have to get up and ask somebody else what they think, or pull out a piece of scratch paper and scribble down an equation to work out the problem. Also, when you get more into programming, you will not might not even start writing the code until you have created a diagram/architecture beforehand.

I was taking a data structures course when I was in college, and was having trouble designing a sorting algorithm. When I asked my professor for some help, he knew that I hadn't thought about the problem beforehand. The first thing he told me was that I was not ready to begin writing the code yet. So he pulled out a piece of paper and drew a couple of squares, and then he put in the numbers from the array. Next he drew a couple more pictures where he move the squares around and showed me visually how the sorting algorithm would work.

Some things you can do to clear your mind and solve the problem:

  • Take a break
  • Talk to a colleague
  • Whiteboard the problem/concept
  • Sleep on it!

Don't be surprised if you wake up in the middle of the night with the solution.

1

I think it will surely help to become an efficient professional programmer/developer if you can. However, thinking about a problem while translating the solution into program logic IMHO needs training, so I see no problem if you serialize these tasks - you just need to be able to successfully complete both. Thinking about a solution from start to end before starting to code surely has its merits, but you need to be a somewhat patient character for this.

Not the answer you're looking for? Browse other questions tagged or ask your own question.