8

...in percentage. For example 60/40 or 90/10 or 100/0.

My hypothesis is that the bigger the proportion of time you spend thinking the smaller your code can be as a result (and the less time will be needed to write it down). Think more, write less, in other words. Do you think it is true?

As a side note, I think in typical software companies thinking is not part of the culture anyway: you are usually supposed to be sitting there at your computer typing something. You will almost definitely be noticed by your managers if you wander about with a blank look thinking over your next steps with your code. Too bad.

6
  • 1
    Possibly similar: programmers.stackexchange.com/questions/12696/…
    – Chris
    Nov 5, 2010 at 15:30
  • 1
    @Chris: not exactly, that question is about coding versus "Reading around the subject, improving knowledge, learning new things", which is not exactly thinking over your actions. Although yes, thinking is mentioned in some answers.
    – mojuba
    Nov 5, 2010 at 15:32
  • This is just a more precise question than that one. You are asking for coding:thinking time, that question is coding:<anything except coding>. Similar enough to me.
    – Chris
    Nov 5, 2010 at 15:33
  • 2
    @Chris: absolutely not. Huge difference between thinking over your next steps vs. any activity other than coding. What I'm trying to say here is that you may improve your code by thinking more before you start coding.
    – mojuba
    Nov 5, 2010 at 15:37
  • 4
    I can strongly recommend thinking while you code, too.
    – user1249
    Nov 5, 2010 at 16:01

12 Answers 12

9

I code in last resort.

Say 50% thinking, 50% coding including 10% implementation and 40% debugging.

5
  • Excellent, I think 50/50 is just the right proportion although it would seem nonsensical to many.
    – mojuba
    Nov 5, 2010 at 16:25
  • 2
    Yes it's counter intuitive to the factory-production view of mind. You have to understand that programming is all problem solving, not code "manufactoring", before agreeing that you'd better think a lot before acting.
    – Klaim
    Nov 5, 2010 at 16:34
  • surely debugging can include thinking as well
    – jk.
    Feb 21, 2011 at 13:23
  • Obviously, yes. But in fact it's still just the mind process of problem solving, while coding and debugging while coding is more mechanical, more low level. You could think of thinking as making up a strategy, while coding is applying it, using tactics to adapt your strategy to the context.
    – Klaim
    Feb 21, 2011 at 20:28
  • Before manufacturing happened, someone had to spend a lot of time thinking and tinkering to perfect that product...so there is a lot of thinking in manufacturing too...it just happens more up front...and often by a different person.
    – CaffGeek
    May 20, 2011 at 19:01
10

As with anything else, it depends

At the beginning of something, the majority of time is spent thinking and planning how to code it. Once you have the plan in place, most of the time is spent coding.

1
  • +1, It doesn't make sense to generalise. The ratio would be very different for implementing a B+ Tree than for writing CRUD operations. Feb 21, 2011 at 16:16
5

60% Thinking / 40% Coding

I'm not just thinking at work. I'm thinking everywhere I go. I tend to not begin coding until I have thought through all the possibilities. I'm not talking about writing code in my head, I'm talking about doing the stepwise refinement in my head.

3

Some days I write a single line of code, yet get more work done (in getting the application working) than the next day that I write a thousand. My manager would call the first day wasted, he looks at LOCs produced per day to gauge productivity (or they used to, less so these days).

Am I thinking less the second day? Maybe, depends on the type of coding at hand (if it's mindless querying of a database I've done a thousand times already it's not much of a mental challenge).

2

Shorter code is generally better but not always.

Why punish a developer who has increased fluency through experience and knows exactly what they are doing? Every line of code doesn't have to be your first rodeo.

Don't assume because I'm typing that I'm not thinking. Typing doesn't take that much mental effort.

Planning is very important, but not to be confused with thinking about your code.

1
  • That's a good point, I actually meant thinking about your code more than planning/designing the product as a whole.
    – mojuba
    Nov 5, 2010 at 15:50
2

In contrast to most of the "% spent thinking" > "% spent coding answers" above, I'm (somewhat to my surprise) finding that currently my productivity is correlated with my keystrokes. The "currently" is key: I'm learning a new language/system, and I simply learn more when I get my hands dirty and build stuff and break stuff and figure out how to fix it than if I sit back and try to think through it all, which often turns into unproductive brooding about how over-complicated this stupid thing is.

(I wouldn't usually bother answering a question with an already-accepted answer, but this got me thinking & I couldn't help weighing in.)

1

When I plan out a problem in detail before starting to code it, I find that I make way fewer revisions. I think it takes a lot of discipline to not go straight into the code, but is worthwhile. Unfortunately, as you have noted, most non programmers do not understand that time away from a computer to plan and think first might actually speed up and improve a task.

1
  • At one company I worked for we had a lot of small meeting rooms, and it was OK to be there alone for a while, provided that you are holding a pen and a notepad and have a thoughtful look ;)
    – mojuba
    Nov 5, 2010 at 17:08
1

I'm pretty sure I understand your distinction between thinking and coding. But, why stop thinking when you start coding? Hopefully, typing doesn't take so much effort that you can't think at the same time.

I find that it works well to think for a while about the direction I should head, then start coding while I think about more of the less significant details.

1

How is your working time distributed between coding and thinking?

It depends. At this time of the year, I'm mostly doing bug fixes, so thinking is the majority of my work effort.

As a side note, I think in typical software companies thinking is not part of the culture anyway: you are usually supposed to be sitting there at your computer typing something. You will almost definitely be noticed by your managers if you wander about with a blank look thinking over your next steps with your code.

You will find that this attitude is not limited to software companies. It is a widespread phenomenon in American corporate culture. My experience is that managers who spent significant time in the military (or when younger in military styled schooling) pick up a habit of always be working. If your Seargant catches you not working (and since thinking is not visible to an external viewer, thinking == goofing off), he'll order you to scrub the sidewalks with a toothbrush (or other stupid make-work) just to keep you from goofing off. The all-time worst manager I worked for would intentionally create a crisis in order to make work for you if he catches you doing nothing - and since he was also the owner, he didn't believe that you needed to think about anything, just get it done.

1

How is your working time distributed between coding and thinking?

THEY ARE THE SAME

END TRANSMISSION

1
  • 2
    Someone downvoted you probably for a style that's not welcomed here, but I got your message OK ;)
    – mojuba
    Nov 5, 2010 at 23:01
1

Thinking to me is a way of abstracting coding. You think of the possibilities and their most likely outcome. I think a lot. Sometimes I lie with my head on my desk and my eyes closed. Thinking is the smallest level of design. I Always adjust my thinking length based on the area effect of the code I am about to write.

"Where do i put this button?" gets almost no thinking time, "where do i put this database field?" gets as long as it takes.

Thinking on paper also helps, and it looks a lot more like working and a lot less like day dreaming.

0

it can vary a lot. A lot of my code is the result of a bunch of tools that I wrote. So there are days when I "write" a huge amount of code, almost none of it by hand. And there are days when I think I spend more time with a pencil than I do with my keyboard.

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