Search This Blog
Tuesday, October 12, 2010
Sunday, October 3, 2010
Troubleshooting - why isn't it working?
This may sound silly, but your program isn't smart. It will only do what you tell it to do.
So when you say, "Why isn't this thing working?" the answer is almost always, "Because you told it not to."
Working incrementally toward an objective is a good idea. By this, I mean I've found that taking small steps is a good strategy. Instead of building the entire program and seeing if it works, make the building blocks work as you're creating your program.
Visual Basic may not be quite so easy. You may need to build up the foundation before you can test your program.
Here are some tips I hope will be helpful.
So when you say, "Why isn't this thing working?" the answer is almost always, "Because you told it not to."
Working incrementally toward an objective is a good idea. By this, I mean I've found that taking small steps is a good strategy. Instead of building the entire program and seeing if it works, make the building blocks work as you're creating your program.
Visual Basic may not be quite so easy. You may need to build up the foundation before you can test your program.
Here are some tips I hope will be helpful.
- Use break points (in Visual Studio). At certain points within your code, you'll expect things to happen. You may expect an array to be populated, a variable to be filled or a counter to be incremented. Using a break point to inspect the contents just may give you the clue you need.
- Use var_dump(). In PHP, var_dump() is not to be underestimated. Knowing the state of objects and the contents of variables is never more than an echo statement away. For example, instead of using echo "$variableOne"; you should use echo var_dump($variableOne);. If you had instead used an echo statement, you will receive no output if the contents of $variableOne are null. Using var_dump(), you will either see that the variable's contents are null, or a description of the variable itself and also the contents.
- Finish everything that you start. When creating tag pairs in HTML or XML, create the pair and then fill in the text and attributes. This should keep you from later inspecting each element from line 1 down, looking for an elusive closing tag.
- Use a good text editor. You can write code in any language with notepad. However, it won't help you with indents. Or color coding. Or tag matching. Using a text editor like Komodo-Edit (http://www.activestate.com/komodo-edit/downloads), NotePad++ (http://notepad-plus-plus.org/download) or JEdit (http://www.jedit.org/index.php?page=download) will save you time and errors. These are not the only full-featured text editors, but they should get you started.
Coming prepared
If you're reading this, you're taking a big step: asking for help.
In order to make the most of our time together, please take a moment to read the following tips. Hopefully this will shorten the amount of time we will need to fix your code.
In order to make the most of our time together, please take a moment to read the following tips. Hopefully this will shorten the amount of time we will need to fix your code.
- Read your assignments. Often, your instructor will assign material to read. This material should reinforce in-class lecture and exercises. Additionally, the textbook may contain exercises you can follow along with.
- Search the internet for solutions. A good student is resourceful. With the world's information at your fingertips, you should not be afraid to step outside your textbook for answers.
- Get organized. You may find that assignments are sometimes large and overwhelming. Though it's good to understand "the big picture" and what's required, programming is accomplished by breaking big steps down into little steps. I've found that printing the assignment and checking off tasks as I accomplish them helps. You can also write notes about things you have difficulty with or have questions about.
- What output are you expecting? What have you tried? What were your results? This goes hand-in-hand with #3. Being able to methodically note your efforts will save much time troubleshooting.
- If you're able, work together with your classmates. Your instructor will likely approve of you working with others. Each instructor has different policies, though, so check with him or her at the beginning of the semester.
- If you don't understand something in class, ask a question. Chances are very good that someone else also has that same question. Don't be afraid to speak up. This also applies to assignments. Do take the time to read the assignments and understand each requirement. Your instructor will explain activities you may have difficulty understanding.
- Don't wait until the last minute to do an assignment, especially large projects. Most of the subject matter is new to you. Because of this, you probably don't know how long a project or assignment will take. Give yourself plenty of time to try different approaches, and write down questions. Coming to class prepared and asking questions before the project or assignment is due will help you and perhaps even your classmates.
- Lastly, an additional suggestion. Attend other sections of the same class, if they're offered. You've already paid for the course, you're welcome to attend the same course at different dates/times. Perhaps going over the material again, or hearing it explained differently will help.
Subscribe to:
Posts (Atom)