Lab 10 FAQ
General Recommendations | Debugging Advice | SocialNetwork class | FaceSpace program
General Recommendations
- Ask yourself the questions that I/the student assistant asks you when you're stuck solving a problem.
- Test each class before moving on to the next class so that you find problems early
- Comment your code! Commenting helps you remember _why_ you coded something the way you did.
- Think about what data you have access to and what data types they are. The most common issue I see is students forgetting the variable's data types and what you can do with that data. Perhaps draw yourself a picture of the data, to remind yourself what you're dealing with, since the ideas are abstract. I also recommend naming your variables in ways that help you remember the data type to have less "cognitive strain". Refer to the APIs for the data structures (you should have handouts for all of these).
- Look at Piazza for answers to questions that others have had. Submit your own questions too.
- Look at previous examples/solutions that solve similar problems to what you're facing. You have read files, you have formatted strings, you have used dictionaries (in class and in labs). Review the examples and remember what you did and why you did that.
Debugging Advice
- When you run into problems, print out variables or other information that may be useful to make sure that the variables have the values that you expect.
- Make sure you adhere to the data types expected for the parameters to methods--check the comments to confirm what should be passed into the method. For example, ids are strings. You can choose to make ids integers, but that will have a far-reaching effect on your code, so think about that choice carefully.
SocialNetwork
Reading in the People File. When you read in from a file, what does every line end with? How will that affect your code? Anything you should fix?
Reading in the Connections File.
We solved a similar problem in terms of reading in this
file format in class when we read in the file with the format
name year
on each line.
Face Space
Command-line Arguments. Look at the example code from Tuesday. You may want to copy the program into IDLE. To test the command-line arguments, you need to run the program from the terminal. The idea is to make testing the program easier with a variety of files used as inputs (without having to retype the filenames).
You do not want to write your code exactly as this. How is your code different?
Recommendations:
- When you're implementing the user interface for FaceSpace, write
down the APIs for the
SocialNetwork
andPerson
classes or use, for example,help(Person)
so that you can refer to it. The code for the UI should be fairly straightforward because you're simply leveraging the APIs of the classes that you already wrote. Do NOT rewrite code that you already implemented in theSocialNetwork
orPerson
class.In CSCI209, we use the Java programming language, which makes it easier to use the API without these manual steps.