Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

My workflow has always been to write one logical step and then run the program and inspect the output. This process have served me incredibly well for assignments in university. However, as I do more development, there are often times when simply compiling and running your code takes 1 to 2 minutes. Examples include uploading a program to a microcontroller, requiring interaction with an external server, and unable to implement automation due to authentication, software architecture, or complexity.

These types of tasks are very unsuitable to how I usually program, and I'm having difficulties coding effectively. I usually make a lot of syntax errors and logic errors, most of which I easily catch by testing. However, with such a long wait time, this method is too time consuming.

share|improve this question
    
Are you using an IDE? –  Woot4Moo Jun 9 '11 at 14:22
3  
Your root problem isn't being unable to code effectively, it's tests that take too long to run. You're asking the wrong question. –  Rein Henrichs Jun 9 '11 at 19:39
    
Use a language that has a REPL. –  Robert Harvey Jun 13 '11 at 20:31
add comment

7 Answers

Unit Testing; Mock applications/simulators.

This will take time, granted, and you may need to collect and massage sample data to create appropriate mockups, but it will pay off in the end: Used correctly, these tools will ensure that before you go anywhere near external systems, you're 99.9% sure that if your code fails, it's something in the external system/change of environment that caused it, not a bug in your own code.

I worked professionally for quite a while they way you did in school - eventually I worked under some people who forced me to abandon that methodology, although in many cases it was very effective.

Now, ten years later, I do not start any project without first thinking through the implementation of the testing phases - unit testing, mock-ups, simulators, sample data, etc.

HTH

share|improve this answer
add comment

I would work hard to reduce the test time. I had worked in a couple of companies developing embedded code, and testing was painful, requiring trips to the server room and manual FTPs and reboots and multiple commands to the test hardware. Then I joined a really good group, where I could simply type 'make test' at my desk and get results back in under a minute. In that one minute:

  • My code was built into a new kernel image for embedded hardware.
  • The DHCP server was updated to point to the new kernel.
  • The test board was rebooted.
  • The test board retrieved the kernel from my workstation via an NFS mount.
  • The test board rebooted to the new kernel.
  • The unit tests were run.
  • The unit test output was delivered back to my workstation.

It took some time to get all this working, but the effort to automate all these steps was recouped a hundredfold as the development staff grew.

share|improve this answer
1  
+1. There is no problem that cannot be solved with a sufficient amount of shell script. –  Tom Anderson Jun 9 '11 at 14:19
    
I won't stay in teams that don't care about improving velocity. –  kevin cline Jun 9 '11 at 15:23
    
@Tom Except too many layers of abst--er, shell scripts ;) –  Darien Jun 9 '11 at 17:37
    
Nah, you just write a shell script which wraps the other shell script. Then there's just that one shell script. TRUST ME. –  Tom Anderson Jun 10 '11 at 8:55
2  
+1: Improving the velocity of edit -> compile -> load -> run -> debug -> edit is the single best thing you can do to speed code production. When I worked at Tymshare we had a guy who claimed (correctly) that his code ran correctly on the first try 87% of the time. I, on the other hand, coded like I was overdosed on caffeine monkey at 1am (which I was). I made a ton of typo errors, etc., but I didn't worry about them because I knew the compiler would catch them. At the end of the day I was probably 3 to 5 times more productive than he was. –  Peter Rowell Jun 10 '11 at 19:33
show 2 more comments

The real fun comes when you simply can't test your code except by using it in anger. This happens quite a lot with trading systems, as the exchange simulators available are often either poor, non-existent, or don't even comply with what the suppliers of the exchange software say it does. This is part of life's rich tapestry I'm afraid. My approach is to make sure at least my side of the transaction is well-written and well-documented, so it can easily be changed quickly.

share|improve this answer
2  
You "exchange" and "trading" software engineers are a unique breed. My friend had a series of mental breakdowns working for one such company. I never hear good things come out of that niche of the software industry. –  maple_shaft Jun 8 '11 at 20:14
    
@maple Well, I don't do it any more myself. But unique? Nah - anyone can write crappy code, and most trading code is deeply, deeply crappy. However, like it or not it, is the basis for our society. –  nbt Jun 8 '11 at 20:23
    
Yeah, I heard the same thing about telecom code and how many millions of lines were in switch control software. Then I joined a Telecom company and realized that if they had employed some programmers thousands of lines would have been sufficient. –  kevin cline Jun 9 '11 at 5:06
add comment

Automated tests are not replacement for review and understanding.

It may be that you are using testing as a crutch. If you are doing this you will impede your learning. I am not advocating you don't test. Instead I would recommend you that before you run your test review what you wrote. Understand what you wrote, make sure it makes sense and make sure the syntax looks correct.

share|improve this answer
add comment

You need a good Unit or Functional test platform that can automatically run tests for you, preferably in the background. This will require the use of Mocks as noted above and depending on the language you are using some sort of dependency injection.

By making your objects as independent as possible and then using injection methods to add outside constraints it is not hard to create a test platform for your code.

share|improve this answer
add comment

First off, any sort of interactive debugging is great. You want that in your toolkit, because if not yet, then someday you will really benefit from having it. (Details vary by language, platform, and IDE.)

requiring interaction with an external server, and unable to implement automation due to authentication, software architecture, or complexity.

I'd look into some frameworks for using mock objects. These allow you to surround the component being tested with a fake ecosystem of other components, so that your tests are more specifically-targeted and you can avoid testing everything as a whole unit as much.

In addition, the mock objects themselves can be programmed in with assertions, so you can check that the component-being-tested really did make a certain call.

share|improve this answer
add comment

You already gave the answer: I usually make a lot of syntax errors and logic errors

So working hard on improving that, you should be able to reduce the time on testing. The syntax errors should be the very first you should reduce. Never had a programming test with a paper and a pencil in your study?

I had the same thing when I switched from PHP to Java. I had to learn to debug instead of just printing some variables and press F5 in the browser...

share|improve this answer
2  
We all make stupid mistakes from time to time, they only occur less with time and experience. –  maple_shaft Jun 8 '11 at 18:41
    
@maple_shaft thats true, but when he says make a lot of it sounds like he should invest his energy to improve it –  WarrenFaith Jun 8 '11 at 18:57
3  
I did a fair amount of coding on paper and on whiteboards. The problem is the same: the code looks right on the first inspection, but after running it, you notice your mistakes. –  Anne Nonimus Jun 8 '11 at 19:10
    
noting mistakes in code and writing code with wrong syntax is a big difference. The first one can happen to everybody, the second one suggest beginner level. I do not know your background, but even as a beginner you should minimize syntax issues. Whats your IDE and language? It should support syntax checks. –  WarrenFaith Jun 8 '11 at 19:21
    
@Anne Nonimus: Do you mean logical errors? Syntax errors should be picked up by your IDE (ideally - if you are working with code that's dynamically generated then those syntax errors will not get picked up at compile time). –  FrustratedWithFormsDesigner Jun 8 '11 at 19:24
show 1 more comment

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.