Sunday, 15 February 2015

Object-Oriented Programming

This week I need to write a post about Object-Oriented Programming. Although I am not really sure what I should write about it, I will try to express here whatever I know about this paradigm. Object-Oriented  Programming is a concept in computer science that views computer program as a combination of data structures. So far in this course we have mostly worked with classes, their attributes and methods. 

In the first two weeks of the course we have studied the concept of inheritance which allowed us to create subclasses, and format or create in them new methods, which were not implemented in the super class. Basically, methods that are specific to a certain subclass, when written in a superclass, can only raise a “NotImplementedError”. This happens because super class does not contain methods for specific subclasses, but only indicates methods and attributes common to all the subclasses. When we write the subclass, the general information will be inherited from the super class, and we won’t need to implement this part of the code again. However, if we want to add some more specific methods to the subclass, we are free to do so without changing the super class. 

Designing classes and subclasses is not very difficult - you just need to know what is the purpose of your code, what it should do when executed, and which methods and attributes you will use for it. Also, making up proper names for your methods and writing clear docstrings can be very helpful. 


I had a couple of problems with with class design in the beginning of the course, but the first two labs and writing assignment were very helpful in clarifying these concepts.

No comments:

Post a Comment