The first topics assigned from CSC148 before the long weekend are Object-Oriented Programming, and Recursion.
One reason, and probably the main reason for assigning these as topics is that they all are the characteristics of Python. Object-Oriented Programming is a way of programming using objects rather than using instructions. For example, Python codes a class object that has certain attributes and methods under itself. In such way, it allows the programmers to develop, edit, and easily analyze the program as the objects are independent from other objects, yet dependent on what belongs to itself. As an object, we can analyze and look over the whole thing while we can still separate each objects to spot the errors. Imagine us programming in a non-Object-Oriented language, it would probably take us a huge amount of time to think on how to structure it out to start working on it.
Then it comes to Recursion, which plays a critical role in programming to make the codes as neat and simple as possible. Recursion is a method of calling the function in that function itself. When we program something, we frequently encounter a task to repeat some steps. This is where the Recursion comes in handy because it allows us to simply call the method itself inside that certain method to repeat itself. Although it is hard to come up with the way to use Recursion for beginners, every time I see the codes that uses it, I am amazed at its structure because the codes can never represent the task any better.
If I had known that I had to post on this blog although there were no topics assigned, I probably have written down about the lab 4 last week. It was a task about coding a binary representation, calculating the decimal number to a binary number. It involved steps of dividing the number into 2, adding the remainder, and then calculating from the number we have left after dividing it. We can still code this with a While loop or If statement, but with Recursion, this code ended with one sentence.
P.S. Happy Thanksgiving! XD
댓글 없음:
댓글 쓰기