Sunday, 8 March 2015

Week 7: Summary of Abstract Data Types

In the past few blogs, since I have already more or less summarized recursion and object oriented programming topics, I wanted to explore a new subject for this week's slog. Although I myself am still new to this topic, I will try my best to recap what I have learnt so far about abstract data types.

Before I begin, when you first hear the term "abstract data types", what do you think it represents? A cryptic piece of code that is so clouded in mystery that we can only try to fantasize about it in our heads? I know that that was first thing I thought of when I first heard this term. In reality, abstract data type is a lot simpler than recursion which is as abstract as it can get.

From my understanding of abstract data types, there is a parent class and a child class. The parent class is a generic abstract class which cannot be used to achieve anything on its own. However, when used with the child class, the child class inherits the parent's general attributes and methods which can be used to perform a function. Moreover, you can add new methods to the child class which are specific only for that class. For instance, when we created the game state class for assignment 1, it needed a specific game to work with it. The subtract square state class inherited its parent class (GameState) and was then able to use its attributes such as next_player, over and even instructions which were modified for subtract square. We even added a new method called is_pos_square() which was game specific.

In summary, I believe that abstract data types are a vey useful tool especially when creating games or for anything that needs a general template which then can be used for specific purposes without having to be redundant and repeating our code. I am more comfortable with ADT than recursion because it is not as intangible of a topic as recursion where I have to spend hours just thinking about how it works. Thus, I hope that in the next few lectures we have left, we can focus more on understanding recursion and Trees.


No comments:

Post a Comment