oop设计 [英] oop design

查看:109
本文介绍了oop设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我读了很多关于如何以OOP方式制作Javascript程序的内容。

之后我下载

许多第三方库(比如YUI,原型ecc。)而且我已经看到了

几乎

所有函数(类)的设计都像文字对象符号和

不正常

的方式就像我学到的......现在我很困惑

关于如何设计我的类...我来到了Java / C ++体验......


似乎用对象文字表示法我们无法制作所有的OOP

构造

我们可以使用普通的Javacript类创建构造...所以

为什么它如此大量使用?


谢谢

解决方案

9月10日晚上7:45,josh< xdevel1 ... @ gmail.comwrote:




我读了很多关于如何以OOP方式制作Javascript程序的内容。

之后我下载

许多第三方库(比如YUI,原型ecc。)而且我已经看到了

几乎

所有函数(类)的设计都像文字对象符号和

不正常

的方式就像我学到的......现在我很困惑

关于如何设计我的类...我来到了Java / C ++体验......


似乎用对象文字表示法我们无法制作所有的OOP

构造

我们可以使用普通的Javacript类创建结构...所以

为什么它如此大量使用?



这可能有所帮助,尤其是关于面向对象的最后一点:


< URL: http://www.crockford.com/javascript/javascript.html >


-

Rob


On 10 Set,11:45,josh< ; xdevel1 ... @ gmail.comwrote:




我读了很多关于如何在OOP中制作Javascript程序的内容办法。

之后我下载

许多第三方库(比如YUI,原型ecc。)而且我已经看到了

几乎

所有函数(类)的设计都像文字对象符号和

不正常

的方式就像我学到的......现在我很困惑

关于如何设计我的类...我来到了Java / C ++体验......


似乎用对象文字表示法我们无法制作所有的OOP

构造

我们可以使用普通的Javacript类创建构造...所以

为什么它如此大量使用?


谢谢



我没看到RobG回答......


9月11日下午4:54,josh< xdevel1 ... @ gmail.comwrote:


On 10 Set,11 :45,josh< xdevel1 ... @ gmail.comwrote:




我读了很多关于如何制作的内容Javascript pr以OOP方式的图表。

之后我下载

许多第三方库(比如YUI,原型ecc。)而且我已经看到了

几乎

所有函数(类)的设计都像文字对象符号和

不正常

的方式就像我学到的......现在我很困惑

关于如何设计我的类......我来到了Java / C ++体验...



Javascript doesn没有类,它有对象和通过原型链继承的形式

。它在链接I

中提供了解释。


似乎用对象字面符号我们无法制作所有的OOP

构造

我们可以使用普通的Javacript类创建构造...所以

为什么是它如此大量使用?



因为它是制作对象的有效方式。虽然有些图书馆尝试制作像

这样的东西,因为他们的作者认为假装javascript更简单是

OO而不是试图理解javascript。


例如Prototype.js有:


var Class = {

create:function(){

return function(){

this.initialize.apply(this,arguments);

}

}

}


哪个(惊喜)只是一个使用一种方法的对象文字。


我提供的链接包含了制作javascript的方法的其他链接

模拟类的一些属性。


我没看到RobG回答...



你的意思是没有看到,因为没有得到它,或者从字面上看不到,因为

根本看不到它。这是链接:


< URL: http://www.crockford.com/javascript/javascript.html >


Hi,
I read a lot on how to make in Javascript programs in a OOP way. After
I download
many third-party library (like YUI, prototype ecc.) and I have seen
that almost
all the function (class) are designed like literal object notation and
not in a normal
way like I learned ... now I''m confusing
on how to design my classes... I came to a Java/C++ experience ...

It seems that with object literal notation we cannot make all the OOP
constructs
that we can make with normal Javacript class creation constructs... so
why is it so largely used?

Thanks

解决方案

On Sep 10, 7:45 pm, josh <xdevel1...@gmail.comwrote:

Hi,
I read a lot on how to make in Javascript programs in a OOP way. After
I download
many third-party library (like YUI, prototype ecc.) and I have seen
that almost
all the function (class) are designed like literal object notation and
not in a normal
way like I learned ... now I''m confusing
on how to design my classes... I came to a Java/C++ experience ...

It seems that with object literal notation we cannot make all the OOP
constructs
that we can make with normal Javacript class creation constructs... so
why is it so largely used?

This may help, particularly the last bit about Object-Oriented:

<URL: http://www.crockford.com/javascript/javascript.html >

--
Rob


On 10 Set, 11:45, josh <xdevel1...@gmail.comwrote:

Hi,
I read a lot on how to make in Javascript programs in a OOP way. After
I download
many third-party library (like YUI, prototype ecc.) and I have seen
that almost
all the function (class) are designed like literal object notation and
not in a normal
way like I learned ... now I''m confusing
on how to design my classes... I came to a Java/C++ experience ...

It seems that with object literal notation we cannot make all the OOP
constructs
that we can make with normal Javacript class creation constructs... so
why is it so largely used?

Thanks

I don''t see RobG answer...


On Sep 11, 4:54 pm, josh <xdevel1...@gmail.comwrote:

On 10 Set, 11:45, josh <xdevel1...@gmail.comwrote:

Hi,
I read a lot on how to make in Javascript programs in a OOP way. After
I download
many third-party library (like YUI, prototype ecc.) and I have seen
that almost
all the function (class) are designed like literal object notation and
not in a normal
way like I learned ... now I''m confusing
on how to design my classes... I came to a Java/C++ experience ...

Javascript doesn''t have classes, it has objects and a form of
inheritance via the prototype chain. It is explained in the link I
provided.

It seems that with object literal notation we cannot make all the OOP
constructs
that we can make with normal Javacript class creation constructs... so
why is it so largely used?

Because it is an efficient way to make objects. There are no classes
in javascript, though some libraries try to make things like there are
because their authors think that it''s simpler to pretend javascript is
OO rather than trying to understand javascript.

e.g. Prototype.js has:

var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}

which (surprise surprise) is just an object literal with one method.

The link I provided includes other links to ways to make javascript
emulate some of the attributes of classes.

I don''t see RobG answer...

Do you mean don''t see as in don''t get it, or don''t see literally, as
in can''t see it at all. Here is the link again:

<URL: http://www.crockford.com/javascript/javascript.html >


这篇关于oop设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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