Week 4 in the course introduced to us the concept of recursions in programming. Recursion was mentioned numerous times throughout csc148 and was shown for the first time this week. Since this year was my first time doing computer science, it is my first time seeing recursive functions. Some people had already seen this type of programming in other languages and programming courses they may have taken. After learning about the concepts behind recursion, i can see how this style of coding can be beneficial to many problems. This style of programming allows for the user to get his answer by running the code until the value that it needs is met. The code will continue to run by itself through the recursive function calling itself. Special precautions must be taken however since in some cases, the code may run infinitely long and thus result in an error. Users using recursion must have statements in their code that tells the recursion to stop running when a certain case is met in order to avoid this error.
Other concepts in computer that was learned this week is creating test cases for our own code. This was done in our tutorial time as we had to write objected oriented programs and then write auto-tests to test our code. This may seem like a waste of time at the moment because our code is short but when our code becomes complex, it will become extremely useful to test it automatically rather than manually. The exercise this week had us explore the exception class and write our own functions that calls upon these functions. This week had been great in learning about recursive functions as well as testing and the exception class.
No comments:
Post a Comment