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.
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.
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.

No comments:
Post a Comment