Agreed. I often know where I want to go but can't seem to get there with code. This sucks and good programmers must find a way to get through this.
A crucial skill in programming...is the ability to recognize when they’re stuck,
Yes, and this is the only time I ever measure lines of code. Here is my metric: If I've been sitting at my computer (developing, not testing or anything else) more than one hour and LOC written or changed = 0, then I'm officially stuck, and must move to GettingUnstuck mode.
to get out of being stuck,
The most effective way I've ever found to get unstuck is to get away from the computer. I take pencils, paper, and code listings and get away, always into another room, sometimes to another building.
I have learned that the reason I'm stuck is not because I don't know how to do something; it's because I don't know what to do. What needs to be determined away from the computer; how can be determined at the computer.
and to avoid getting stuck in the first place.
This is the one time I disagree with OP. Getting stuck is not the problem; getting unstuck is. If you're not getting stuck on a regular basis, then you're probably not working on big enough problems.
Never getting stuck makes programming like almost any other vocation. For me, getting stuck and then getting unstuck and making something cool work for the first time ever is one of the best feelings you can have.
I got this trick from working in a metal shop. We'd get stuck trying to solve a problem all the time, and whenever that happened we'd simply start cleaning up. Usually after cleaning up the 'way forward' was crystal clear.
Now, of course one day there will be a problem where this will not work but for now it seems like a really good trick.
The underlying mechanism is as far as I can see related to being stuck in the same cycle in your head. As soon as you start cleaning up you force yourself to look at the forest instead of the individual trees and that's where you'll find the key for moving on.
ymmv, it works for me.
I've dropped out of college (a really good one, you should know it) because I couldn't afford it any more and I'm now working as a .NET web developer (4 years) with people clearly less knowledgeable about programming and the internet in general.
The most senior dev guy (works there for 14 years) is a cocky jog who only knows VB.NET, who advocates the use of POS content management systems such as DotNetNuke. His code is such a bad and unmanageable mess, I could supply thedailywtf with code excerpts for the rest of eternity. When you try to explain concepts such as anonymous methods to him his head explodes.
Do you think we have code versioning? Do you think we freeze functionality, have releases, or even any sort of requirements for our custom modules and libraries? No, every fucking web site has a slightly different version, it's a pure ghetto.
Sometimes I slack off for the entire day, browsing reddit, and with 30 minutes of coding I'm still more productive than any of ny work mates.
These guys don't know what the "cascading" in CSS stands for. "What is a selector?".
When I started I had to fix the all of our web servers, they crashed every day because of simple configuration mistakes.
These are guys that set up the dbs with a full transaction logging only to delete the transaction logs every day because they're getting too big.
"We" now made the decision to move like 400 web sites, (some of them are nationally known and get a lot of traffic), sites that expose public web services, sometimes have custom services running in the background that require os access, and more, to a SHARED web hoster where we don't have any other access than PLESK. Without any migration plan. Bringing up VPS or dedicated hosts will give you empty stares. They now started migrating and realized that well, it's not going to work out like this... durr... "what do we do now?"
These guys make CMS updates on a live server without informing the customers, if they're having a good day they at least don't forget to make a db and site backup first. Ah yeah, we also don't have staging servers. So most of the guys do development on live sites.
I tried to change things, introduce new practices, I tried really hard. But now I'm just bitter. Before I was a nice and outgoing guy, now I'm not even advocating for alternatives and I stopped giving input.
Man... I'm about to throw up
Get out. Now. I spent about 5 years in a job that initially taught me a lot about a lot of different technologies, but I peaked very quickly. I felt like I couldn't leave, however, since I was easily the most technical and was responsible for lots of disparate systems. So, I would go to work and spend 95% of my day chatting on IRC and 5% of my day writing a solid chunk of code that made it look like I was busy.
The biggest regret I have is that I spent at least 2 years too many at that job before I grew the balls to change my life. Don't waste another day of your life rotting away in an environment that's doing nothing for you.
"with 30 minutes of coding I'm still more productive than any of ny work mates"
Use the rest of your time on research and planning for your own business. Don't actually do work on their computers, but research is fine. Feel absolutely no loyalty to the company. I guarantee they have no loyalty to you.
Usually having to make coherent statements about a thing causes me to realize what I am failing to put together.
Also, often whatever obvious thing I am failing to see stands out clearly to someone with fresh eyes. Those eyes could be someone else's. Or they could be your own.
Did you know that the human eye constantly moves around even when its staring at something? If it didn't, the same exact stimulus would eventually be invisible to it. They've held eyes completely still in the lab and kept the stimulus the same and eventually the eye stops seeing anything.
The same thing can happen to your attention when it constantly focuses on a problem.
This is not an admission of failure. This is not an admission of incompetence. It's an admission that you're stuck. It's an admission that you are human. It's recognition that the project is more important than your ego. It's a chance to communicate with your team. It's a chance to laugh at your oversight. It's a chance to improve.
Just ask. No harm will come of it. And the chances are very high that you will become unstuck.
Spinning your wheels for too long doesn't help anyone, but a lot can be said for people who are independent and don't needlessly distract those around them.
"Mutt can't remember the name of the Unicode version of the strcpy function. He could look it up, which takes 30 seconds, or he could ask Jeff, which takes 15 seconds. Since he's sitting right next to Jeff, he asks Jeff. Jeff gets distracted and loses 15 minutes of productivity (to save Mutt 15 seconds).
"Now let's move them into separate offices with walls and doors. Now when Mutt can't remember the name of that function, he could look it up, which still takes 30 seconds, or he could ask Jeff, which now takes 45 seconds and involves standing up (not an easy task given the average physical fitness of programmers!). So he looks it up. So now Mutt loses 30 seconds of productivity, but we save 15 minutes for Jeff."
Granted, interrupting a peer makes more sense if you actually can't make progress without another opinion on design, rather than just being lazy and using them as a living reference work.
Debugging on Windows, is a prime example. If you take someone from the normal Visual Studio give give them a PDB file, the compiled executable, limited / no source code, a crash report and a minidump, they're going to be stumped looking on the internet for some resources and instructions on how to debug the program.
Others include debugging in general, making the switch to and working in a *NIX environment (ie. sans IDE) from Windows, adding functionality to a large enterprise application that doesn't have comments or documentation (so essentially you're stuck for 3 hours trying to find this interface to that will execute a command), and so on.
Developers, please take pride in great documentation, and if you get stuck due to someone else's shitty docs, tell them at least, at best: fix the docs yourself. You can often write great (passionate) docs if you just had hands-on experience with the pain-points.
Also, make sure your examples work (examples+tests are often the best docs)
___ “Okay,” I say. I tell him getting stuck is the commonest trouble of all. Usually, I say, your mind gets stuck when you’re trying to do too many things at once. What you have to do is try not to force words to come. That just gets you more stuck. What you have to do now is separate out the things and do them one at a time. You’re trying to think of what to say and what to say first at the same time and that’s too hard. So separate them out. Just make a list of all the things you want to say in any old order. Then later we’ll figure out the right order. ___
Pirsig is talking about writing here, but he also applies it to motorcycles and it can apply equally well to programming. The key thing is that stuckness is inside your head, and having tools to get yourself unstuck is vital.
I sometimes find myself procrastinating, not able to get my head into the game.
And it _always_ turns out that I'm afraid of something. That there's something lurking ahead that I don't know what to do about - lacking requirements, a problem I don't know how to solve, technology that's being a massive pain to work with in the past.
The thing that works for me is stopping, working out where the fear is coming from, and then taking a bit of time out to work out what the solution is. Once I've done that my productivity skyrockets.
(Ok - that sounds like a load of crap ARobbins might spout.)
Stuck is the result of not knowing where to - and your reluctance to - begin.
I've had been cleaning up a mess of code that I've ported from a book whilst changing parts to fit my needs. I've got stuck on the process of cleaning up and now I'm going to reread the book and try to understand the concepts fully to then write my own code based on my understandings.
Even though I already considered doing that I still felt completely demotivated. The discussion here and the quote from the zen-book made me reconsider my options and think about what the correct next step would be.
I'm feeling relieved.
That said, usually when I feel like I've started spinning in circles I take a break, come back and ... delete the whole thing. Start from scratch.
I find this frees me to solve the problem with a new pair of eyes and from a different angle. most of all, my thinking isn't bogged down by everything I've already done.