Sunday, 23 February 2014

OOP -- What is OPP (Object-Oriented Programming) ?

What is OOP(Object-Oriented Programming), my partner and I met this question during the first lab of this course. Now half time of this course has gone, and we should have better understood the meaning of OOP and how to use it, but the first lab really gave me and my partner deep impression about OOP.

The first lab, our main task is to count the number of occurrences of words in a piece of text, and store the words with their frequency, find the "top n" words, and compare one collection to another. We thought it was not difficult, after a short discussion, we started to code. We knew how to open a file, read file, split, strip, and get a list of words. We use "for loop" to check every word in the list, find their frequency, and store them in dictionary, words are the keys and frequencies are the value. Every thing went smooth well. After we finished coding and implementation, we shew our work to TA. To our big surprise, TA told us that what we were required was Object-Oriented Programming, and what we did was just a procedure, though it was program, but not what this lab asked. Then we read the lab handout again, this time we found something we missed: "Perform an object-oriented analysis of the specifications in specs.txt". We just did discuss how to make the procedure and how to make it work on Python, but ignored the key word "object-oriented analysis, or we simply did not understand what it meant. We had to redo it: find the major noun and write the header for an appropriate class definition, along with a short docstring for the class; then find the main verb and write the header for an appropriate method, along with a short docstring for the method, and so on...

This first lab did give me a deep impression on OPP.

No comments:

Post a Comment