Take the 2-minute tour ×
Personal Productivity Stack Exchange is a question and answer site for people wanting to improve their personal productivity. It's 100% free, no registration required.

I am currently studying Informatics and Computer Science. Cause I know there are quite a lot of programmers here on SE, I would like to ask for advice on speeding up my coding.

First, a brief outline of my problem:

  • things that other students solve within 10 minutes, I solve in days;
  • during tests that are intended to check our knowledge of language and contain several problems to be solved in 30 minutes I usually have completed only the "algorithm" part, because when I start coding, my thinking is as slow as a broken down snail;
  • I miss almost all of the deadlines;
  • practice,practice and practice doesn't help - no improvement.

Second, what I am not doing:

  • procrastinating - concentration on the task is as deep as possible;
  • waiting until the last minute- it is not for me, I start my work almost immediately;
  • skipping the theoretical part - I orientate quickly in algorithms and remember by heart what library functions perform, the structure of classes, syntax etc.

So, I tried to solve the problem by hiring a tutor who could help me debug and generate code (i.e. not write it for me, but sit nearby and give advice). This helped for the part of deadlines, but not with the speed of my coding.

Then, I had an idea to practice with a timer on - but I don't know how much time a professional programmer needs to complete each of the tasks. So I either set myself too much time and this leads to no result, or on the contrary too little time - and I get disappointed. As a conclusion, the speed of my thinking doesn't improve at all.

I would also like to add that with math classes everything is just fine and adding the timer solves all the speed problems. Probably it's because I started programming without any previous experience. But isn't two years enough to catch up to one's course mates?

Any other ideas of how to speed up?

share|improve this question
3  
This question will be impossible to answer without understanding where in the process you fall over, which would require pairing/observing, then analysis. –  Dave Newton Apr 24 '13 at 2:23
    
+1 for really good question. –  Md. Mahbubur R. Aaman Apr 25 '13 at 11:54
    
Do you have similar problems in math and/or language classes? –  JeffO Apr 29 '13 at 11:48
    
@JeffO, no, not at all. Foreign languages are my hobby and I learn easily and very fast (able to complete elementary course in 3 months in a completely new language). Same with programming languages. My mathematics is a bit worse (it takes time to understand the concepts and train myself), but I am still able to speed up with the help of a timer. –  petajamaja Apr 29 '13 at 15:46
    
I postet an answer that is perhaps relevant to your question as well: productivity.stackexchange.com/questions/6978/… –  mrsteve Apr 29 '13 at 16:16

15 Answers 15

up vote 14 down vote accepted

Some great advice in the other answers already. I am also facing the same challenge.

Things that have helped me the most are:

  • Get as fast as you can at typing - do typing lessons, make sure you can touch type, even buy a better keyboard if it helps
  • Learn keyboard shortcuts and let go of the mouse. Keyboard shortcuts make me orders of magnitude more effective
  • Consider buying a tool like "Resharper" (if you are in Visual Studio) or look at what tools can provide to generate code or give "code snippets"
  • Read code - find the source code to projects and frameworks you already use, and read the source to see how it was written and what choices were made
  • Figure out what the "minimum viable" code is - try focus on solving the problems with the least amount of code possible. Count the number of lines of code and challenge yourself to solve the same problem again in 50% of the number of lines of code, for example.
  • Spend some spare time editing and answering questions on StackOverflow.com
  • Take a look at http://codereview.stackexchange.com/ - the Code Review site, and post some questions asking "how could I do this more simply or in a more straight-forward way
  • Look at the Code Golf Stack Exchange site - it is specially great at making you cut down the number of lines of code used - http://codegolf.stackexchange.com/ but watch out you don't get depressed or overwhelmed ... happens to me :-)
  • Figure out if you have a "detail" oriented personality - you might be getting stuck in too much detail that your examiner / professor is not interested in
  • Try find roles in the future where speed is less of an issue. Some software development roles are more focussed on "quality" or other requirements, so speed might not even be a problem
share|improve this answer
3  
IMO, shortcuts definitely help. They give a smoother workflow, so you spend less brainpower thinking. –  Muz Apr 25 '13 at 15:32
    
Sure =) Shame on me, but before entering the Uni I didn't know about ctrl+V, ctrl+C etc, and even no ctrl+S, so I saved and copy pasted everything with the mouse... Now that I recollect those times, it sounds terrible =) –  petajamaja Apr 25 '13 at 23:03

RualStorge already mentioned it but I want to re-iterate that Test-Driven Development can really help here, because:

  1. It helps you focus on creating just the code you need to add to make the test pass. Narrower focus means less choices means faster coding.
  2. It helps you hammer out your API/class structure/etc while you are making it, forcing you to think as a client of your code. This helps you see global issues with your code, allowing you to re-write sooner.
  3. It catches bugs sooner and it catches side-effect bugs when you later add code elsewhere.

Automated tests are awesome. They are especially awesome in weakly-typed/classed languages like JavaScript where they replace compile-time tests with more accurate behavior descriptions. I wish I had learned to write tests earlier - start now.

If it's a bit hard to get going on writing tests, just try to think of what you want to test, how you would test it manually, and then reproduce those steps in code. Simple tests are best. Look into testing frameworks for the language you're writing in.

Here's a great article on testing: "The Way of Testivus".

share|improve this answer

I'd like to distill some of the great suggestions from above and summarise it from the perspective of someone who is maths-heavy and code-lite like you, but codes every day.

You have a very strong skillsket for understanding the concepts behind the code. This makes your strength understanding the problems and understanding the language in how it works. You're also likely to be a very good problem solver. Use these traits!

  • Plan before writing code - I use entity relationship diagrams (UML works too) to think through how my different objects or entities interact, and I draw high level flow diagrams / processes that I drill down through before I start typing
  • Read a lot about the why - syntax and specific values can be googled, but you will struggle if you don't understand how everything hangs together
  • Design patterns - again this is part of understanding why but it is so very rare that we do anything in code that cannot be generalised back to a type of interaction or problem that has been encountered thousands of times before. By researching design patterns and looking at how you can take a step back from the minutae of the problem to the structure of it, you can more quickly understand all the components you will need.
  • Don't 'roll your own' - leverage frameworks and modular systems that do common tasks for you. Your job is to solve a problem, not write code!

Most importantly - do not consider your current code speed as being too major an issue. The person who solves the issue completely is preferred to the person who doesn't solve the problem but does it quickly. Also, as you become more quickly able to abstract to patterns and re-use structures and frameworks your code speed will increase dramatically over time whilst your understanding will still be rock-solid and your resultant code-quality high.

share|improve this answer

I would guess you have a problem with coding rather than programming (you know what to program but not how to structure the code?). I'm surprised no one has mentioned programming competitions as a fun way to improve.

There are several aspects to speed-coding, including knowing the algorithm, implementation tricks, and general implementation ability. If you're already at a limit with the first two, you may be looking for the third. You may be looking for the coding equivalent of Czerny exercises, i.e. speed through mindless, automatic improvement of muscle memory. This means repetition.

Try the "A" problems from the past 5 years of e.g. http://www.acmicpc-pacnw.org/results.htm. They are not trick questions. Start by working with a friend (maybe your tutor). Copy their code. Also, this won't show results immediately, but when we started, it would take us 45 minutes to do them. Now it takes under 5.

Ask around for people who compete in, say, ICPC. Warning: you will learn bad practices, but it will improve your speed, make you aware of bad practices, and make you a better coder.

share|improve this answer
    
Wow,such an impressive answer!I never ever distinguished programming and coding,isn't it the same thing? Yes,implementation ability is exactly where my mind stops. Besides, at University we have each subject taught in a different language/requiring different software (e.g. this semester I had to learn from scratch Scheme,Haskell,Prolog,Assembler (MIPS),Matlab,and Prover9 + coding in Java and C) and I have hard times getting used to each language.As for competitions,I have always been afraid of them, because of my lack of skills.But I will try out tasks from previous years, this is a good idea. –  petajamaja May 4 '13 at 11:20
    
Thanks for the kind words. I don't know if others distinguish between coding and programming, but I call programming the part you can do in the park with a pad of paper (e.g. pseudocode), and I call it coding when you actually choose a language and code up the solution. To me programming is the hard part and I think you're lucky that the math comes easy and you just have to work on the coding part. –  Sephra May 4 '13 at 14:14
1  
Wow, that is a lot of languages. I would be surprised if you -didn't- have difficulty. One of the things I tell people when they tell me they are no good for programming competitions is that it is a poor excuse. Not having time is understandable, a valid excuse. But everyone I know who does it waits until their senior year and then regrets not doing it sooner. "If only I thought about this when I was a freshman, imagine how good I would be now!" (hint hint) Let me know if it would be helpful to have reference solution code for some of the problems. I know it helps me. –  Sephra May 4 '13 at 14:14

You might be slow because it isn't clear to you how to solve the problem.

Maybe start by spending some time thinking about how you will solve the problem using some kind of diagram notation, like UML, or by writing down a todo list of all the steps you will need to do in order to complete the tasks.

share|improve this answer

I'm a former college instructor as well as someone with a bit over 10 years as a software developer...

Don't let efficiency concern you too much as a student. Some of my most successful students came to me with stories of how they spent days on stuff I could hammer out on a lunch break. (Do this for ten years and I promise you, you'll make most "fresh outta college" kids feel completely inadequate.)

For your purposes I'm not sure whether you mean the actual typing of code is getting you, or coming up with the specific implementation plan is getting you. (taking the problem and planning out the solution) So I'll give you suggestions for both...

If you're taking too long physically writing code (not the planning side)

  • Write more code (Sounds obvious, but this is REALLY an experience thing)
  • Try to avoid repeating code, if you have a calculation you're going to use several times instead of writing it out several times create a method that has the calculation and just call it wherever is appropriate
  • When you get your implementation plan create all the empty methods, functions, classes, etc. With comments for what they are supposed to do (input vs output) If you have the structure in place before you start it helps keep you from writing any code more than you need to. (You'll be amazed how quickly a very simple solution can be over complicated from lack of planning before hand, and how often plans are forgotten/confused if not documented someplace)

If the implementation plan is tripping you up...

  • Try having a peer provide you with a simple solution, only they've removed several method calls from it. Basically you've got all the pieces you need to accomplish your goal, but you need to figure out what needs to be called where and when. (you may not add any code that is not required to accomplish the goal)
  • Try taking a Test Driven Development approach (if you have the time to learn this) this basically means you write something to test each piece of your code before you write a single line of code. It forces you to plan things out before hand which is typically what slows people down.
  • One piece at a time. One thing people do that kills them later is try to do too much at once. Write some code, fire off the debugger and make sure it works, write some more. If you try and hammer out an entire solution without running the debugger until the end it is effectively a form of self inflicted torture.
share|improve this answer
    
+1 for Test-driven development and One piece at a time. The less code you write before you validate that it's working, the quicker you will become. –  Torbjørn May 10 '13 at 23:18
  • Don't repeat yourself = duplicate code should be avoided (and duplicate thinking too)
  • Don't reinvent the wheel = use a good framework (get your tasks done with fewer lines of code)
  • Say good by to "not invented here thinking" and use all the goodies available out there (I bet you find solutions for allmost all tasks in the web)
  • use the best code editor you can find - with code completion and snippets
  • set yourself goals and achievements (when I complete this task I reward myself by...)
share|improve this answer

Since you are a student, you're working on problems that others are working on as well, so try and compare your code to theirs.

  1. Are you writing more or less code to solve the same problem?
  2. Are your solutions more complicated?
  3. Are you working on the solution the whole time or are you stuck on problems and staring at the screen?

Things you can do:

  1. take an online typing test. Not that being a super fast typist is necessary to program, but you can't hunt and peck 10 wpm either.
  2. Focus on getting your code to work. DON'T try to be perfect the first draft. Come back later and improve the formating or refactor as time permits. This doesn't mean keep refactoring until it is perfect. You have to budget your time and know when to stop.
  3. The speed of other programmers is no help when you have deadlines. You must get things done.
  4. You may need to get some help if you think this is an anxiety problem.
share|improve this answer

Practice will definitely help. If you're practicing right, it should feel difficult and you'll struggle to understand what you're doing. If you're comfortable with the practice and feel it as too boring and repetitive, then you're not learning anything new. Set the bar a little higher, so that you're always uncomfortable.

There's a theory that learning to play music helps brain development. Personally, I feel that this is because the people who learn to play music will reach a point where skill gain plateaus and practice doesn't seem to make a difference. However, they all find that after increased effort and practice, their fingers seem to just magically hit the right notes.

While you're finding it difficult, you should focus on doing a few, intensely focused short hours instead of long, unfocused hours.

For more details on this, look at the book Mastery by Robert Greene.

Also, you should always be breaking down your code into some kind of plan. Just a really rough pseudocode will do. Don't be too accurate as you rarely know the details. Tools like Workflowy can do wonders.

share|improve this answer

Although your main concern is about your coding speed, my advise would be to focus on making sure that when programming, you are solving the right problem, in the most efficient way possible. Speed is not the most important aspect in programming. Many programmers quickly produce buggy applications and are not abble to maintain it on daily basis. Your interviewer will mostly be impressed by your thinking process rather than your coding speed. He will be impressed by the running time of your algorithm,.rather than quickly producing a naive costful solution.

Hope it helps!

share|improve this answer
    
Well, thanks for the information about interviewers! I will certainly try to focus on efficiency during interview, too. –  petajamaja Apr 25 '13 at 14:16

Several of the other answers on this page jump to providing solutions without first understanding the problem. In my view, this is a mistake.

As as CS student you undoubtedly know that, in order to optimise code, you need to:

  1. Determine where the bottlenecks are so you can target your efforts where they'll be most effective.
  2. Use objective measures so you can be sure you aren't making things worse - either within the bottle neck or globally.

The same principles apply to improving your own performance.

Identify the Issue

The first thing you need to do is to isolate the areas where you need to improve your speed. Be as precise as you possibly can.

For example:

  1. Do you find it difficult to understand the problem's requirements?
  2. Do you have a problem choosing the overall approach to meeting the user's needs?
  3. Is your typing speed the problem?
  4. Do you have trouble applying algorithms to real world problems?
  5. Once you have a solution in mind, do you struggle to articulate it?

These are, of course, just suggestions: you need to study your own behaviour, and then to isolate the areas where you need to improve.

There are several approaches you could use here:

Compare your performance with others.

Bare in mind that when you're watching other developers, much of their "programming skill" is hidden, as it goes on in their heads. You may need to get them to articulate what they're thinking in order to figure out where you are currently falling short. Even then, what people say is going on in their heads isn't always very accurate. Also remember that you're you, not anybody else. Your strengths and weaknesses are different from other people's, and you will do better if you capitalize on your own strengths rather than try to fix your weaknesses.

Work out where you spend most of your time

If there is a specific area that is really slowing you down, working on that area will often improve your overall performance. Of course, optimising a single area can actually make other areas slower... but generally this approach works well.

Look for low-hanging fruit

When you start analysing your behaviour you might find that there are some easy wins. These might be worth your attention. Even small improvements can add up to big ones.

Don't limit yourself to single tasks: consider how they inter-relate

You can loose a lot of time task-switching, or by doing tasks in the wrong order.

Measure

Once you've narrowed down your issues very precisely, you then need to measure your current performance in that area. The reason for this is that you will benefit from some objective means of determining whether or not you're getting quicker. This isn't always easy, and I wouldn't spend more time on this than necessary - a rough measurement will probably be enough - but you don't want to fix a bottle neck only to discover that this has made you slower overall.

Make Improvements

Now it is time to move on to solutions, and some of the other answers already posted will almost certainly help you here.

You have two basic approaches:

  1. Improve your performance in areas where you are weak.
  2. Leverage your strengths to "hide" your weak areas.

For example, one of the things that makes me a slow programmer is that my memory is shot. To help me deal with this I could try to deal with the weakness by, for example:

  1. I could learn simple memorization techniques
  2. I could practice remembering things by playing memory games

Or I could mitigate my need to remember things by employing my strengths:

  1. I could learning to re-think out solutions rather try to remember them
  2. I could improve my Google skills
  3. I could use crib sheets

As I have mentioned, building on strengths is usually more effective than focusing on weaker areas, but it is up to you to find the best approach for you.

Practice

This is really the only way you'll get quicker at anything.

There are two schools of thought here: one is to go fast and worry about quality later. The other is to focus on quality and then learn to go fast later. There are things to be said for both approaches: you'll have to see what works for you.

Final Thoughts

I don't suppose that everything I've written will be useful for you, but I hope it will stimulate your thinking and help you find solutions that work for you in your situation. All the very best.

share|improve this answer
    
This. Thank you sir! –  grunwald2.0 Apr 27 '13 at 22:30

Suggesting on the basis of what I do;

For fast reference/look up

  1. Prepare a library (a project) contains usage of all libraries you know technically.
  2. Prepare a library (a project) contains highly moduler, generic, customizable code, and algos. So you can copy paste them in your any other code

For fast recall

Above practice makes you habitual of copy pasting. You starts forgetting syntaxes which affects your performance. So write code yourself as much as possible.

choose the way suites to you.

share|improve this answer
    
I will certainly try this out! –  petajamaja Apr 25 '13 at 2:46

Try doing the work with a friend who is better in coding.. You'll soon learn to think quickly or think similarly..

For me, I was also slow in the beginning, but i realized i am much better now with some practice in error checking.. I mean i tried to find and rectify errors in my friends' code and guess that helped me...

And sure there is no substitute for Practice.. All the best..!

share|improve this answer
    
Thanks @Shaima =) –  petajamaja Apr 25 '13 at 2:45

Basically all of these suggestions imply obtaining a deep understanding of the programming language in question. The better you know the language, the better you can code in it.

  • Stack Overflow is a great resource. I use it all the time.
  • Get the best programming book you can find and read it cover to cover. Then read it again. You'll be better equipped to solve programming problems.
  • Make sure you're in an environment conducive to coding. Eliminate all the distractions you can.
  • Work through internet tutorials. They can be a great learning experience.
  • Surround yourself by a group of people who are willing to help. This can be a group of friends, a job, or an online forum.
  • Don't ask for help until you have extensively tried to solve the problem. The more work you put in, the more less time you will spend messing up and relearning.
share|improve this answer
    
Fine, that's what I do on a daily basis. Any methods to increase speed, not the understanding? –  petajamaja Apr 23 '13 at 20:21
4  
For strictly increasing speed, there's no better substitute than learning and practicing. Run through code you have already worked through. Type it all out again to solidify the algorithms you have learned. You will then be able to apply these learned algorithms to new tasks that will inherently increase speed, as you will already have a set of basic strategies to work from/ –  Marcus McLean Apr 23 '13 at 20:23
    
So your advice is - when I complete some small problem, try to do it once again without looking into the solution, so that it is learnt by heart (solidified). Right? –  petajamaja Apr 23 '13 at 20:26
1  
If I understand you correctly, yes. If you have the time, wait an hour or two to revisit the problem. Learn concepts and basic algorithm models by heart so you can reference them in your mind for later use. –  Marcus McLean Apr 23 '13 at 20:30
2  
The repetition of coding solutions to the same problem again and again is useful - it is not so much about "learning by heart" - although this aspect helps - it can also be focussed on incrementally learning new, small things that can be done smarter or faster. Each time you repeat the solution, you learn something new. This time, a new keyboard shortcut (e.g. how to comment out multiple lines of code) that cuts down the number of characters you need to type. The next time, you learn about a new keyword that solves the same problem in fewer lines of code. And over and over, better each time. –  GrahamMc Apr 24 '13 at 18:40

How fast or how much you code is generally not a good metric to judge programmers by. What matters is primarily the method you use to solve the problem; algorithm, programming paradigm, data structures.

That said, if your peers indeed are 200 times faster than you when implementing functional solutions, you need to question whether a career in Computer Science is right for you. That difference sounds overwhelming.

If you conclude that CS is for you, you need much more experience and training. Everything is hard in the beginning. And as a CS engineer you will face new languages and techniques your whole career -- so you will be in a never ending learning phase.

share|improve this answer
2  
Sorry, this answer doesn't actually provide any methods to speed up (which is my aim so far). I wasn't asking about what one needs to become a programmer. Maybe I should edit the question so that it is clearer what I expect. –  petajamaja Apr 23 '13 at 19:49
    
Even if it is not a good metric, it is still relevant when preparing for an exam or - later - for an interview (where you generally have to solve problems in a limited time,too). –  petajamaja Apr 23 '13 at 19:52
    
Maybe I was a little exaggerating when talking about time differences. But this is how I feel, because after the tests most people have everything completed, and I try it out myself after the test and it takes much much longer. –  petajamaja Apr 23 '13 at 19:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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