Issue: Getting it working
Key skill: problem decomposition
Let's look at a simple example. We're not really even going to look at the code, which is fine. Download this zip file into a directory, unzip it, and open a command prompt/terminal in the same directory. The zip contains three files:
- HelloWorld.py – the standard Python "Hello World";
- HelloWorld.bat – a file to let us easily run the program on Windows;
- HelloWorld.sh – a file to let us easily run the program on Macs and Linux.
So, our bat and sh scripts should run the HelloWorld.py file. At the command prompt, run the right shell script by typing HelloWorld. The right shell script for the operating system should execute, but if it doesn't, add the .sh or .bat file extension. Note that if we just double-click the files in a file explorer, the command line will flash open and then disappear, making it hard to read what's happening, so we'll run by typing for the moment.
Ok, so, it doesn't run. This is a shame. The question is, can we fix it? Let's decompose the problem. What we need to do is break down the problem into its component parts, and work out a test for each. What are the component parts here? See if you can write a list before going on to the next part. Order them by how potentially tricky you think they'd be to test and solve. Here's a start:
- Our typing of the shell script name.
- The python script that is run.
- ?
- ?
- ?
- Start
- The problem
- Decomposing the problem <-- next
- Testing the parts
- Solving the issues 1
- Solving the issues 2
- Final points