Today we are going to talk all about memory. There are multiple types of memory when it comes to software, but for now we are only interested in two of them: the Stack and the Heap. Whenever we execute a program, its instructions are loaded into the RAM of the computer, and the operating system will allocate a bunch of physical RAM, so that the executable can run.… Read more
Archive for the ‘Debugging And Error Handling’ Category
Stack vs Heap memory
Wednesday, August 15th, 2018Breakpoints and local variables
Wednesday, August 8th, 2018Breakpoints are arguably the most used feature in the process of debugging. As their name suggests, they are literally a point where the execution of your program will break, or more precisely, will pause. Whenever the execution of a program is in this paused state, which isn’t design time, but it’s neither runtime (you could say it is an intermediary between these two states), we say that the program is in debug time, or debugging mode.… Read more
First steps in Debugging: understanding common errors
Tuesday, August 7th, 2018As I said many times, debugging is the process of correcting errors in the codes of your programs. That is only partially true. Debugging is also about understanding the error and understanding why the bug was there in the first place.… Read more
The Using directive
Sunday, August 5th, 2018.NET provides a simplified and easier way of working with resources that needs to be disposed (released when we no longer need them) through construct called a Using directive. Here is an example of how we can read a filename (just like in our previous two lessons) and automatically release it when we are done dealing with it, using this keyword:
1 2 3 4 |
using (StreamReader reader = new StreamReader(fileName)) { // Use the reader variable here } |
By enclosing the declaration of our reader variable inside the using instruction, we can use it just as we normally would, but we don’t need to worry about releasing the file when we are done with it.… Read more
Try Catch Finally
Friday, August 3rd, 2018Continuing from the last lesson, we now know that every time we deal with codes that might generate errors, we should use a Try Catch code construct. You should also know that this great construct offers one more great feature, a Finally block.… Read more
Handling exceptions with Try Catch
Thursday, June 28th, 2018Exceptions
Sunday, June 17th, 2018In an ideal world, a computer program will execute anything the programmer intended, the way the programmer intended. But since we don’t live in an ideal world (sadly), there are moments when due to the programmer’s mistake or to external conditions, these programs will malfunction or function in a way not intended, causing an exception from what we would normally expect.… Read more