CS 202 Fall 2013 > Notes for Thursday, September 19, 2013 |
CS 202 Fall 2013
Notes for Thursday, September 19, 2013
Classes I Day 4
For today’s lab work, see the the 9/19 Challenge.
Most of the class period was spent on the above; here are a few points I brought up.
Development Methodology—A common mistake in software development is to think of ourselves as “done” when we have written a package and are about to test it for the first time. But really, debugging takes up more time than writing; if you have not ever executed code, then you are nowhere near done working on it.
Here, then is a better approach.
- Your first goal is to get your code to compile.
- Once it compiles, make sure it always compiles.
- Since it compiles, you can test it; do so often.
Somewhat counterintuitively, this approach means that you test code even when it is not complete, and you know it does not work properly. Such testing tells you just how it does not work and what you have left to do.
Using an Integrated Development Environment—Most of us do our programming using an IDE. It can be helpful to understand how these are designed.
- First you create an area to do your work in. This is generally called a workspace or a solution. A single workspace/solution may contain multiple projects.
- A project is supposed to contain everything necessary to put together a single runnable program. We compile, link, and execute projects.
- Only one project executes at a time. Generally, you get to specify which one. In MS-Visual Studio, for example, the project that runs is called the startup project. To select a new startup project, right-click on a project name and choose “Set Startup Project”.
So for example, when doing an assignment for this class, you could create a workspace/solution for the assignment. This would contain one project for each program you are to write. When you do run checks, open the workspace, set one of the projects as the startup project, and run it. Then set a different startup project, run that one, etc.
A couple of final points:
- It is critical that project files be stored in the proper directory. Just because a file is listed with a project, does not mean it is stored in the project directory. I recommend that you never add an existing file to a project. Rather, use the IDE’s tools to create each file. If you already have code written, then copy/paste it into the file that was created.
- MS-Visual Studio is not primarily aimed at the kind of programming
we are doing.
It will try to lead you in other directions;
you need to be firm with it.
In particular, when you create a new project,
it should be a Win32 Console project,
and you should click the Empty checkbox.
It is easy to tell if you get this wrong.
You will see a reference to the file
stdafx.h
. When Visual Studio says “stdafx.h
”, it is saying, in its own special way, that you messed up and created the wrong kind of project. Start over.