Thursday, January 23, 2014

Object-oriented Programming

        Object-oriented programming (OOP) is a very amazing invention in the field of computer science. Python is the only OOP language I have exposed to, but I found it is very powerful. Other object-oriented programming languages should be similar to Python, since they are all based on the same paradigm. On the other hand, I have read some computer science related job posts from different companies. Most of their job qualifications require the knowledge about any of the following programs: C++, Python, Java, or Ruby (all of them are examples of OOP languages). I guess it will not be very hard to learn others if we master one of them.
        So far in Python, I understand how to use the existing types of objects to store information and simulate real life situations. Also, using methods to complete different kinds of tasks. Other than those built-in classes and functions, we can create our own classes as well as its attributes and functions in order to achieve more complicated goals. Just like the class "Stack", we created in the past two weeks' lectures, we added and modified its attributes and methods to make it more convenient for our situation.
        However, I found that it is quite easy to be familiar with a object-oriented programming language, but it is really hard to be fluent in one. I can make a new class, and use it to work with a small amount of data with no problem. But as the data quantity increases, more problems show up. In this week's lab, I created a similar class to Stack, called "Queue". The only difference between those classes is in one line of code in one of their methods. The methods are used to remove data. But Stack removes data from the end of a list, Queue removes data from the beginning of a list. When we do the running-time tests , we see Queue took a remarkable longer time to finish the task for the same amount of data. We found out what the problem is, every time Queue removes data from the beginning of the list, the whole list has to shift forward by one. We tried to find a solution. But with our current knowledge about Python, we could not fix this issue. From the lab, I learned OOP languages can be very flexible. There are a lot of ways to achieve a goal, we just need to figure out the best one for our situation.
        I guess I will have a really long way to go before I become an expert of object-oriented programming languages, but it is really fun and worth to work with. I am looking forward to learn more things about Python and other object-oriented programming.

3 comments: