From Wikipedia, the free encyclopedia
基於原型編程(英文:prototype-based programming)係物件導向編程(OOP)嘅一種做法,指個 OOP 程式唔會明確噉定義「類別係乜」,而係以物件做出發點[1]:
攞一嚿物件 A; 建立一件新嘅物件 B,並且指明 B 繼承嗮 A 啲特性同方法(A 係 B 嘅原型); 跟住可以用同樣嘅方法建立更多嘅物件;
喺廿一世紀初,主流嘅 OOP 係跟基於類別嘅做法嘅,不過都有唔少編程工作者比較鍾意用基於原型嘅做法,例如有啲工作者指出,基於類別嘅做法通常都係會將個程式啲類別定死咗,唔俾部電腦喺行個程式期間郁個類別嘅內容,而相比之下,基於原型嘅做法本質上就會容許呢樣嘢,好似係[2]:
攞物件 A 做物件 B 嘅原型; 改物件 B 嘅特性同方法; 攞物件 B 做物件 C 嘅原型;
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.