2014年1月23日星期四

Object-oriented programming

Object-oriented programming, or OOP, is the most common way of programming. It's a language based on describing things, objects with certain variables and functions that refer to properties and actions. In python, class is used to describe an object. A class is like a template of things in the real world which will be used to create specific objects. For example, dog can be class, and each dog with their name can be created as object. There are three benefit of using OOP: Encapsulation, Inheritance and Polymorphism. Encapsulation refer to the ability to create abstract data type that represent feature without including the full detail information of an object. Inheritance is the process which allow the programmer to create new class with contain all the functions and variable of the mother class. It’s convenient for the programmer to create and modify new classes. Polymorphism basically means that we can create different subclass with different properties and behavior form the same superclass depend on what the programmer need.