Monday, 25 January 2016

Week 3 SLOG Post

So far in CSC148 I have learned to build classes in the python programming class as well as a lot of other things that I will touch on a little later in this post.

Having taken CSC108 2 years ago it is a bit difficult to amalgamate my my knowledge from then to the new information that I am learning in this class and that can be frustrating at times. The challenge is something I look forward to as I want to become well versed in programming in python.


I have however acquired a lot of new knowledge and have provided a small summary of the things I have learned and found interesting since the beginning of the school semester. 

Python is an Objected Oriented language and this means the language is modelled around objects rather than actions and logic.


Image result for oopYou can override extend and inherit methods from parents/subclasses.

Generally when implementing classes:
You start by defining the special methods: __init__, __eq__, and
__str__ .Then  you define and create the methods unique to the class. Then create your doctests.




Data Abstraction (Encapsulation and Hiding):
When you create a protected variable it cannot be used outside of the class definition and the the variable is preceded by a single underscore i.e. _var
when you create a private variable it cannot accessed other than within its class.

You can access these variable by creating public getter and setter methods that give you access  to the variable as well as the option to change the variable.