Search This Blog

Thursday, February 26, 2015

What is Abstract Data Type anyway?

Object-Oriented Programming contains other concepts to be designed. One of them is 'Abstract Data Type'. Frankly speaking, I am still not confident to define the definition of Abstract Data Type(ADT). According to the lecture, we abstract data and operations, and suppress the implementation. For example, sequences items that can me added, removed, accessed, specialized list with access to only recently added item, collection of items accessed by associated keys.

Further research provided me better understanding of ADTs.

Basically, ADT is a mathematical model for data types where is defined by its behaviour from the point of view of a user of the data. Integers can be ADT, so can queue, list. Data structures such as queue, dequeue, list, tree, graph, set, which I already learned are included in ADT.


Abstract Data Type
   The picture above shows how ADT can be defined. The video I found on Youtube summarizes and explains well on this subject and it was great help for me to understand.



If anyone interested , watch this video, hope it will help you organize your thought as it did to me. Also, this is the link of the page that contains the above picture. It is a part of free online book called 'Problem Solving with Algorithms and Data Structures using Python' by Brad Miller, David Ranum. This book also talks about basic data structures, sorting, searching, tree which we have learned in the class. I think it could be a good reading for further reference.

http://interactivepython.org/courselib/static/pythonds/Introduction/WhyStudyDataStructuresandAbstractDataTypes.html

In ADT, there are different data structures. Each data structures itself has many things to talk about. My goal from now is, reading about more ADT and study each data structures in ADT.

Sunday, February 15, 2015

Object-Oriented Programming

Object-Oriented programming.

Object-Oriented programming is one of programming paradigms based on "objects" just like its name. What does it mean by 'based on objects'? How do we program this?

The concept of OPP(Object-Oriented Programming) seemed vague. Ok, I got the 'Object' part. Probably related to the using objects. But what does that mean? How do I use it? Just the taking the lecture was not enough for me to understand whole concept of OOP, so I studied about OOP further.

So, yes, Object-Oriented Programming(OPP) uses objects to program. The objects are data structure that contains data and it's also called 'attributes'. In the computer program using OOP, it is constructed on objects and these objects are interact with each other. For example, we have learned how to write classes. This is one way to design object-oriented program.

When I design a class, I initialize objects according to the purpose of codes I am writing. Then, I will probably add more methods that uses objects I initialized to get other result for a class. Like this, each objects are related to make computer program work. As I practice labs and exercises, I learned that using the objects to design program requires well-organized plan ahead what I want to write, proper purpose of classes and right contents in those classes.

A messy plan leads the result nowhere. It is hard to build the entire class and often hard to decide what to write for each methods or even what to initialize for a class. When the plan is well-organized and solid, it is easy to proceed to write. Having a plan also saves lots of time since it gives me a direction to next step. Just like we have a recipe for writing a function, organizing plan is good way to start.

An excellent, motivating plan without specific purposes of class, however, will be like poutine without gravy. One class should contain objects and functions that are relative to class docstiring. If the class doesn't do what is supposed to do, it will create confusion to users and it will be hard to make connect to other classes. Setting the specific purpose of a class and implementing proper methods are absolutely important to OPP.

In OPP, the following concepts are included as well:

  • Classes of objects
  • Instances of classes
  • Methods acting on objects
  • Message passing
  • Abstraction 
All these concepts can be used to design OPP program.

Not only is there Object-Oriented Programming for paradigms, also there are many other ways to design program. I only started to learn OOP, but there are so much to learn in OOP. So far, this is my understanding of OOP.


<Further study for OOP and other paradigms, I leave the Wikipedia link>
http://en.wikipedia.org/wiki/Object-oriented_programming

Friday, February 6, 2015

Recursion? Recursion!

First thing came into mind about recursion was fractal from mathematics. Repeating same process looked like same shape is repeated in fractal.  At first, this didn't seem complex. However, soon after, I could find myself being confused and frustrated. Right, nothing is easy. I forgot about that.  

The handout exercise was not hard. But when I tries to write functions, the errors kept rising. I could tell in which part the recursion occurs. The hard part was the implement. It was quite hard where to put recursive one. And considering all relationships between type contract, return value. Consequently, putting them all together was more complicated than I thought.  

What I expected to happen with my code often did not work properly. It takes time to get my code work properly. (But it feels like endorphins is spreading to every part of my body fast once I figure it out!) I guess, I am not really understanding how it works yet or need more practice and experiment with practice. 

Most of the recursion function bodies were relatively simple and short compares to functions without recursion. Once I solve what exactly recursion does in the function, the solution was simple. All I need to do is think hard to find right recursion case and properly implement. 

This is definitely not easy at all. But If I think about what recursion does and how it works, it  comes to handy tools when writing some tricky codes. While we are learning this, my goal is to understand recursion and make myself comfortable with it.