2015年2月13日星期五

Week 6: Object-Oriented Programming

Based on my understanding, Object-Oriented Programming(OOP) is a programming language model organized around objects. It's all about manipulating objects.

Here's a helpful video I found:

In this video, the teller introduces OOP concepts by explaining some terms first, such as 'module', 'class' and 'object'. 

He prefers to think a module as a collection of classes and a class as a collection of objects. 

To help understand these abstract terms, he defines a 'class' as a blueprint of what you want to create, for example, a buleprint of two-room house. Based on this blueprint, we can bulid houses- concrete froms, instantiation of the class- called as 'object'.  To construct other parts of the city, we need  houses in different structures(two-room, three-room and so on).  A 'module' is a collection of the blueprints of houses in different structures.

  

Since these blueprints are similiar, to make it easier to create new houses, we can copy a part of attributes from the original blueprint, say a two-room blueprint. With the property of inhertance, two-room buleprint can be extended to three-room blueprint by adding one more room. In this example, the two-room bluprint is called 'base class' and the three-room blueprint is called 'derived class'.  

没有评论:

发表评论