跳去內容

基於原型編程

出自維基百科,自由嘅百科全書

基於原型編程英文prototype-based programming)係物件導向編程(OOP)嘅一種做法,指個 OOP 程式唔會明確噉定義類別係乜」,而係以物件做出發點[1]

 攞一嚿物件 A;
 建立一件新嘅物件 B,並且指明 B 繼承嗮 A 啲特性同方法(A 係 B 嘅原型);
 跟住可以用同樣嘅方法建立更多嘅物件;

喺廿一世紀初,主流嘅 OOP 係跟基於類別嘅做法嘅,不過都有唔少編程工作者比較鍾意用基於原型嘅做法,例如有啲工作者指出,基於類別嘅做法通常都係會將個程式啲類別定死咗,唔俾部電腦喺行個程式期間郁個類別嘅內容,而相比之下,基於原型嘅做法本質上就會容許呢樣嘢,好似係[2]

 攞物件 A 做物件 B 嘅原型;
 改物件 B 嘅特性同方法;
 攞物件 B 做物件 C 嘅原型;

而呢樣嘢被指能夠達致一啲基於類別做唔到嘅功能[1][3]

睇埋

[編輯]

參攷

[編輯]
  1. 1.0 1.1 Crockford, Douglas. "Prototypal Inheritance in JavaScript". Retrieved 22 June 2021.
  2. Taivalsaari, Antero (1996). Section 1.1". Classes vs. Prototypes: Some Philosophical and Historical Observations. pp. 44-50.
  3. Dony, Chistophe; Malenfan, Jacques; Bardou, Daniel. "Section 1.2" (PDF). Classifying Prototype-based Programming Languages. p. 17.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy