Coding

Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don't hold it against me. One of the perils of having a 20+ year old website!

This semester I am taking CompSci II, an advanced Java programming course at my school. So I figured I might as well live up to the name of my blog and talk about it. I am not planning on talking about CS I stuff- that is, basic programming- ifs, whiles, fors etc. unless I am asked. I’d also like you to keep in mind that I am still learning the CS II stuff, so if you see something that’s wrong or it doesn’t seem like I fully understand it, feel free to correct me in the comments.
It’s tough to kinda find a starting point for this- so I guess I can go by class. Tonight we did error handling and exceptions. There are 3 types of errors- syntax, logic, and run time. Exception handling is for run time errors, which, if the program is not coded correctly, will make the program crash. This takes away from the robustness of the program, where robustness is the property of reacting “gracefully” (as opposed to “crashing”) when abnormal conditions.
To prevent crashes, making the program more robust, we add exception handling in the form of a try/catch statement. a try/catch statement is set up like this:

try{
-code with possible bugs/errors/exceptions-
}
catch(excetionType1 name){
-how you want to handle the error-
}
catch(excetionType2 name){
-how you want to handle the error-
}
finally{
-statements executed after try and catch sections-
}

The way this is set up, you put code in the try section. If at any time in that code an error occurs (stated in Java as “An exception is thrown”) it will check the catch statements looking for that exception to see how to handle it. Usually, (in my experiences) the exception is simply handled with a print statement stating the error. In the future, I’m sure we will look into how to use exception handling not only to state the error, but also allow the program to keep going, or revert back to before the error. The finally statement will be executed whether or not an exception is thrown.
You can find a list of Java Exceptions here. Once my professor posts his notes on exception handling, I will post them here. Later

Update: Here is that link like I promised.

Similar Posts

  • |

    10 Things Every College Student Needs

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website! As we approach August and people gear up to go back to school, it is time to think of what…

  • |

    Using Remember the Milk for Assignments

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website! After reading about Gradefix over at College V2, I started thinking about the best way for me to keep track…

  • | |

    Random Code Generator 1.0

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website!A couple of weeks ago, when I officially launched the redesign, I mentioned the forthcoming release of a plugin I wrote…

  • | |

    Create a Temp/Splash Page in WordPress

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website!Often times I will be working on a WordPress theme that I want to live test, but I don’t want to…

  • College is not the Best Time of your Life

    We are at the end of April, which means a few things. Soon I’ll be able to smoke cigars on the roof of my building. The sun will be out regularly. People will be graduating from high school and college. When I was in school I heard, “Enjoy college. It’s the best time of your…

  • | | |

    Web Development Resources, Summer 2013

    I have a ton of bookmark folders to help keep myself organized, though to be honest I usually bookmark something and then forget about it. So, while looking through some of my folders, I can across a good amount of web development resources I’ve been keeping. I’ve decided to share them.

One Comment

Comments are closed.