Introduction to Programming
Regardless of programming experience, every user should follow the same basic steps when writing script.
It is critical to thoughtfully design the components of the experiment. Often the simple act of creating a flow chart to represent the experiment can help to remain focused on the task, and not be overwhelmed with the experiment as a whole. It is extremely helpful to think of an experiment in logical pieces rather than the sum of its parts. This is true of experiments in general, but more so of script.
The First Segment
Implement First Segment
Once the task is broken into segments, begin to implement just the first portion or segment. Often users will try to do too much and then lose sight of the relatively simple steps required to reach the goal. Start simple: for instance, if the goal is to display a question on the screen and then collect and score the response, the flowchart might contain the following steps:
- Step 1: Display a word on the screen
- Step 2: Display a question on the screen
- Step 3: Collect a response
- Step 4: Score the response
It is helpful to get through step one before moving on to step two and so on. Start small and build on a solid foundation.
Test the First Segment
Once the first step is implemented, it MUST be tested thoroughly. If a problem is discovered, it is important to fix it now rather than later. Testing is particularly important in research.
Debug the First Segment
Search through the code to find the problem and then correct it. There are many tricks to make debugging less painful than taking a stab in the dark. Debugging tips are included in GENERAL: Debugging .
The Next Segment
Implement the Next Segment
After the first segment of code is thoroughly tested and you are confident that it is working as expected, begin to implement the next section of the task.
Test the Next Segment
Repeat the testing procedure. It is important to be confident in the code.
Debug the Next Segment
Repeat the debugging process if necessary.
Repeat the testing procedure until you are certain that the code is working as designed. When there is confidence in the functionality of the code, be certain to run a few pilot participants. This is critical, because it is often the case that the participant will uncover a flaw. Rather than losing an actual participant, it is best to find the problem with a pilot participant.