[筆記]一些OOP最基本的概念

Object:
*. 一個object最重要的兩個characteristics—state, behavior。(Real-World中的物件也是一樣的概念)

*. State相當於一個物件所有的特徵。例如長度,高度,名稱,種類,顏色等等。

*. Behavior相當於這個物件能做的行為。例如跑,跳,說話,搖尾巴等等。

*. An object stores its state in fields (variables in some programming languages) and exposes its behavior through methods (functions in some programming languages).

*. Hiding internal state and requiring all interaction to be performed through an object's methods is known as data encapsulation

Class:
*. Class相當於做出一個Object的藍圖或是模型,不是instance本身。

Inheritance:
*. Common behavior can be defined in a superclass and inherited into a subclass using the extends keyword.

Interface:
*. Methods的集合,無implementation。
*. API: Application Programming Interface.

Package:
*. 用途相似的類別分門別類放在folder裡面。

留言

這個網誌中的熱門文章

石園二村

雨天的瀨戶內海

2008 我來到了馬達加斯加- Ifaty 3