在哪里可以找到使用 Crockford 的原型继承方法的大型 JavaScript 项目的示例?

发布于 2024-09-14 03:36:59 字数 1539 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

阳光下的泡沫是彩色的 2024-09-21 03:36:59

必须提供一个反遮阳篷;)尽管喜欢看到大型项目也使用它(如果有的话)。我自己很喜欢 Object.create 并且更喜欢它,尽管我从来没有能够在大型项目中广泛使用它,也不觉得它应该如此。

  1. OO 开发者沉迷于“新”操作符,这是一个很难改掉的习惯,而且一看就很容易理解。以经典方式编写的代码现在更容易移交给下一个开发人员,这已经是反对 Object.create 的有力论据。

  2. ES5(下一个 JS 版本)中的 Object.create 功能更加强大,并且与 ES3(当前 JS 版本)中作为填充程序的 Object.create 截然不同。因此,最好避免将 Object.create(目前可用)作为大型项目中广泛使用的策略,因为当 ES5 成为主流时,它的工作方式将与现在可实现的不同。

  3. 大型项目都会使用框架(当你没有流氓 JS“忍者”时,他们坚持从头开始编写所有内容,一遍又一遍地重新发明轮子),并且所有流行的框架都以经典方式促进原型继承。他们可能有一个以 .clone() 或其他形式出现的 Object.create 方法,但它在有关对象继承和子类化的教程和文档中被掩盖了。

  4. ES3 中的 Object.create 无法实现私有属性。我对 Object.create 摆弄得越多,遇到的问题就越多……

我对 Object.create 摆弄了很多,甚至围绕它编写了一个名为“Objection”的小框架(如果如果你有兴趣,你会找到它;)尽管不要链接到 github)和“JSoo”(已停产)。就大型项目的人力资源而言,它太滑稽、未完成和进步,无法成为主流和可维护的。我建议在作为支持者的同时反对它。

Have to offer an anti-awnser ;) though like to see big projects using it as well (if there are any). I love Object.create myself and prefer it, though I've never been able to use it widely in a big project nor feel it should be.

  1. OO Developers are addicted to the 'new' operator, it's a hard habbit to get rid off and easy to understand at a glance. Code written in a classical way is right now easier to hand over to the next dev, which already is a strong arguement against Object.create.

  2. Object.create in ES5 (the next JS version) is immensly more powerful and drastically different from Object.create as a shim in ES3 (current JS version). For this reason it's better to avoid Object.create (as is available right now) as a widely used strategy in big projects as it will work differently when ES5 becomes mainstream than is implementable right now.

  3. Big projects make use of frameworks (when you don't have rogue JS 'ninjas' who insist on writing everything from scratch reinventing the wheel over and over again) and all popular frameworks promote prototypical inheritance the classical way. They might have an Object.create method somehwere in the form of .clone() or something, but it's obscured from the tutorials and documentation in respect to object inheritance and subclassing.

  4. Private properties are impossible with Object.create in ES3. I came across more issues the more I fiddled around with Object.create and boy have I fiddled around with it...

I've played around a lot with Object.create and even written a tiny framework around it called 'Objection' (if yer interrested, you'll find it ;) though refraining from linking to github) and 'JSoo' (discontinued). It's just too zany, unfinished and progressive to become mainstream and maintainable in terms of human resources for big projects. I recommend against it whilst being a supporter.

乞讨 2024-09-21 03:36:59

您可以在这里找到它 适用于 Visual Studio 的诺基亚 WRT 插件 ,诺基亚小部件开发人员的插件。

来自诺基亚论坛:

The Nokia WRT Plug-in for Visual Studio provides features that enable 
the creation, editing, testing, and deployment of WRT widgets from within
Visual Studio.

You can find it here Nokia WRT Plug-in for Visual Studio , a plugin for nokia widget developer.

From nokia forum:

The Nokia WRT Plug-in for Visual Studio provides features that enable 
the creation, editing, testing, and deployment of WRT widgets from within
Visual Studio.
筱武穆 2024-09-21 03:36:59

尝试:http://showroom.auction123.com/auction123/index.html

我们根本不使用 new...我们只是设置函数的结果并将其用作类。

例如:

// CLASS DECLARATION
var ClassName = function() {

  var public;
  var private;

  var publicFunction = function() {
    // DO STUFF
  };

  // RETURN  OBJECT
  return {
     public: public,
     publicFunction: publicFunction
  };

};

最终的回报只是告诉什么将被公开。

通过执行以下操作来实例化它:

var object = ClassName();

try: http://showroom.auction123.com/auction123/index.html

We don't use new at all... We simply set the result of a function and use that as a class.

For example:

// CLASS DECLARATION
var ClassName = function() {

  var public;
  var private;

  var publicFunction = function() {
    // DO STUFF
  };

  // RETURN  OBJECT
  return {
     public: public,
     publicFunction: publicFunction
  };

};

The final return just tells what's going to be public.

Instantiate it by doing:

var object = ClassName();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文