经典与原型继承 [英] Classical Vs prototypal inheritance

查看:27
本文介绍了经典与原型继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读了两者之后,我只是好奇,编程社区如何使用它?在什么情况下?

After reading about both, I just have curiosity, how programming community uses this? In what situation which?

推荐答案

基于原型的继承更加灵活.任何现有的对象都可以成为一个类,从中可以产生其他对象.当您的对象提供多组服务和/或在您的程序到达需要继承的点之前它们经历了大量状态转换时,这很方便.

Prototype-based inheritance is more flexible. Any existing object can become a class from which additional objects will be spawned. This is handy where your objects offer several sets of services and/or they undergo a lot of state transformation before your program arrives at the point where the inheritance is needed.

此处提供了对建模方法的广泛讨论:http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html

A broad-spectrum discussion of modeling approaches is available here: http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html

这篇关于经典与原型继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆