CS112 Frequently Asked Questions

Last updated August 27, 2004.


Homework Submissions

1.1) The Submission Checker won't find README. Help!

The problem is most likely that the file is not named README, but rather README.txt. This may occur when you save your file as README in notepad. Notepad will automatically append ".txt" to your filename, resulting in a saved file with the name README.txt. In order to override this default behavior, you can save your file as "README" (including the quotes). This forces Notepad, or any other application, to save the file with the exact name you specify. Your file will then be named README instead of README.txt

UPDATE I have modified the Submission Checker program to search for README.txt as well. You should no longer be experiencing problems with the missing file error.

1.2) What files should I submit as part of my assignment?

You should only submit the files that Professor Shao requests that you submit. When working with Visual Studio, several files will be created that are external to your actual program, such as a file named AssemblyInfo. These files are primarily used for more sophisticated development and will not be used in this class. Please disregard these additional files when submitting your assignments and submit only what is asked for.

1.3) How do I receive the assignment grading report?

As soon as your assignment is graded, a file named GradingResult.txt will be placed into the associated submission folder.


Programming Techniques

2.1) The output of my console application occurs too quickly for me to see.

This is occuring because your program is executing and terminating too quickly for your eye to see. In order to slow it down, we can insert a statement at the end of our program that asks a user for input. As a result, the program will execute and wait for the user to enter something before it terminates. This will allow you to see what has been output by your program. You should use the following statement to ask a user for input.

Console.ReadLine();

Visual Studio will can automatically deal with this is you choose to run your program without debugging. When this is done, Visual Studio will automatically ask you to a press a key to continue. This method is highly preferred because you will not have to put Console.ReadLine() into your program unless necessary. In order to start your programming without debugging, go to the "Debug" menu and choose "Start without Debugging."

2.2) How often should I comment my code?

Comments should be used to explain what your program is doing or the logic behind your algorithm. Comments should be written to allow a reader of your code to better understand what is happening in your program and to understand the structure of your program. For more detailed notes on style and comments, please visit the Style Guidelines page, aka. How to not lose points from your grade.

2.3) Debugging is taking me forever! What do I do?!

Every program has bugs. No one has ever written an interesting program that didn't have a few bugs to work out. The programmers job is to minimize the amount of time he has to spend bug hunting. Here are some tips on how to do that...

* Write a piece, test the piece

  A lot of students write their entire program, compile it, and then start looking for bugs. Don't do this!

Write your program a piece at a time. If you need a method to take a digit between 0 and 9 and return the english equivalent, just write that method, and then test it. If you need to, make a new file containing just the new method and a main method that runs some test cases on it. Once you're sure the new method works, include it in your final program. If you don't test your methods as you write them, it will be very hard to figure out where your bugs are once you start testing your program.

* Fix one compilation error at a time

  Often, the compiler will report a bunch of errors when you compile your program. You fix the first error only and then recompile. This is because errors interact, and you can't be sure if later errors are really errors or whether they're effects of some earlier error. So work on them one at a time.

* Look for common mistakes

  Most compilation errors are due to a few common mistakes. When you get a compilation error, check to see if it's one of the following to save time:

  • Used = instead of ==
  • Forgot to end a line with a semicolon
  • Forgot to declare a variable
  • Forgot to enclose an if or while condition in parenthesis
  • Forgot to put () after calling a method with no parameters
  • Declared a method that does not always return a value due to an if or switch statement

* Add print statements to figure out what's going on

  If you have no idea why your program isn't working correctly, you should add print statements to your code. If your program is going into an infinite loop, maybe you should add print statements before and after your loops that print out something like "Started while loop that calculates number of digits" and "Ended digit calculating loop". If you see that the loop is starting but never finishing, you've found your problem. Similarly, if you keep getting the wrong answers, print out the values of your intermediate variables. Make sure you label your output so you know what variable you're looking at.

* Don't make random changes

  If your code is making some very small calculation error, it is tempting to start making small random changes (ie add one to this value, use >= rather than > in this if statement). Don't do this! Think about what the problem is, and make your changes based on facts about your algorithm instead of on luck. If you make random changes, they won't fix anything 99.99% of the time, and you will eventually find the problem by thinking through it. But, now that you've found the problem, you've forgotten what random changes you made, so now your still doesn't work. So don't ever make random changes.

* Know when to stop

  You've been staring at the same piece of code for hours. You're tired. You have a headache. Demons are whispering, "Make random changes!" in your ear. When you've reached this point, STOP WORKING. Any programmer will tell you the more frustrated you get, the less useful the changes you make to your program will be. Eventually, your changes will begin to damage your program. So just walk away from the computer, get a coke, watch TV, do yoga, kick your roommate around the suite, go to sleep, whatever. Just put the program out of your mind. You will come back to the program with a renewed sense of clarity. I promise.

2.4 How can I use both Scite and Visual Studio .NET to work on my program? or... Help! I wrote my program in Scite but I can't select the option to make it run in Visual Studio .NET.

If you create, edit, and save a c# code file in SciTE and try to open it in VS.net, you will find that the Build or Run menu in VS.net is grayed and thus are unable to compile or debug the c# program in it. The problem here is that VS.net only compile and debug a project, even if all the useful code are in one .cs file. This is particularly true for console applications.

To solve the problem, you may instead first create a console application in VS.net for each problem in the assignment, then you can use either VS.net or SciTE to edit and run the source code, and in case you need to debug your program, you can do it in VS.net.

Btw: If you directly double click on a .cs file in Windows, VS.net is the default to be opened. If you want to open it in SciTE, use SciTE's "File" menu and select "Open".


CS112 Servers

3.1) I cannot log onto the CS112 servers.

The answer to this question is explained in detail in the Computers section of the course information page.

Remember to select YALE as your "Log on to:" domain. If that option is not available, click the button that says "Options>>". Alternatively, you can use your full email address, e.g. john.doe@yale.edu, as your login name. The password would be the password associated with your netid.


Copyright (c) 1999-2004, Zhong Shao, Dept. of Computer Science, Yale University