I love that feeling. It's rare, and only comes after you've bashed in your head for a long time on the problem at hand that you're finally crystal clear on what needs to be coded. You start programming and initially you face some problems but eventually the code you commit starts to compile with minor syntax errors, nothing catastrophic.
I've only managed to get that feeling only a handful of times when I felt like a God at programming. Being able to think complex structures and methods to work them perfectly. At that time the only thing which slows you is the IDE GUI, and you wish there was some holographic keyboard which codes as you think.
Seems like a lot. Is there any way a programmer could outline what they're thinking of in anticipation of interruptions so that you don't forget where you were? Or is that just the nature of the job?
Sometimes you’re so deep into working through the logic of an algorithm or data structure that you have to start (thinking) from scratch if someone interrupts you.
It’s like someone slapping your plate from your hands at a buffet. I mean I guess you could try to pick up the scattered food from the ground, but you really just have to get in line again.
Not really. The only things a programmer usually writes down is diagrams and stuff that have to do with the logic of the program so that they can figure out how to do something. Most of the other things a programmer has to remember changes quite often and at random times and so it would not be worth writing down to remember.
I find functional programming is good way to do this: if all I care about is the mapping from inputs to outputs (with no external and/or mutable state to worry about), I don't need as much in my head at once.
On the other hand trying to wrap my head around function composition and partial application of functions and/or higher-kinded types while being distracted is just as bad, if not worse.
Eh, most of these are things that aren't immediately relevant, but when you do need to know them, you should be able to look them up in half a second or so. For example, the program you write your code in should tell you which branch you're on, what files are open, and even prevent you from checking in debugging code. You can see what programs are open at all times just by looking down a few centimetres and checking out the taskbar. Finding the correct browser window is always a problem, but it's not usually a memory problem, and more of a faff-to-switch-windows problem.
This stuff is in your head, but in a fairly abstract way. It's sort of like how, after a while, you can generally drive into work completely automatically, without really noticing what you're doing. It takes a moment to get into that mindset when you set off, and it can be a bit of a surprise when you arrive and you'd be daydreaming, but generally it's not difficult.
A lot of the rest of this is stuff that shouldn't be around in your head for very long. For example, the contents of your clipboard should usually last for a few minutes at most, probably closer to a matter of seconds. Commenting should generally happen as you're writing code, to explain why you've done things in a certain way. Documentation is a bit harder, but a lot of companies that require documentation for public interfaces will also have programs called 'linters' that basically run through the code you're writing and remind you about things that aren't necessarily errors, but are generally unhelpful - like undocumented code.
The biggest things you're going to have in your head are data structures, and code flow. Both of these should be as explicit as possible. You should have some sort of type in your code that explicitly says "This is what a <User> looks like", or "This is what a <ShoppingCart> looks like". If you write code that doesn't match the definition of <User> or <ShoppingCart>, things should break really explicitly, so you can see "oh, I forgot that a user must always have an email address", or "oh, I forgot that you can't have fewer than 0 items in your shopping cart".
Similarly, code flow should be explicit as possible, and there's lots of ways of doing this, for example by having as few if-statements or complicated while-loops as possible, and just naming all the explicit operations that you might do using functions.
Of course, getting this right is hard, and this is usually where a lot of the complication in programming comes from. It turns out the real world is really hard to model, and basic operations tend to get more and more complicated, and don't really have obvious simplifications that we can make to them.
View all comments
139
u/Reluxtrue Mar 06 '18
why is he thinking in 2 different diagram types mixed together?