当前在线人数8495
首页 - 分类讨论区 - 电脑网络 - 窗口里的风景版 - 同主题阅读文章

此篇文章共收到打赏
0

  • 10
  • 20
  • 50
  • 100
您目前伪币余额:0
未名交友
[更多]
[更多]
Re: 你们最不喜欢.net的什么?
[版面:窗口里的风景][首篇作者:les] , 2007年03月08日14:53:20 ,3005次阅读,56次回复
来APP回复,赚取更多伪币 关注本站公众号:
[首页][上页] [下页] [末页][分页:1 2 3 4 ]
LifeAsWater
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 44 ]

发信人: LifeAsWater (烟水寒), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Fri Mar  9 15:14:33 2007)

In fact, when you define a delegate, you define a class.

public delegate void Success();
public delegate void Fail();

void Test()
{
}

I can intantiate a delegate Success with method Test.
I also can intantiate a delegate Fail with method Test.

From the OO point of view, Test is sucess or fail, contract is not clear at
all.

【 在 Deling (流浪歌手-爬爬死爬腰酸) 的大作中提到: 】
: you still don't get it. this is not related to "type safety".
: defined



--

※ 来源:·BBS 未名空间站 http://mitbbs.com·[FROM: 65.223.]

 
Deling
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 45 ]

发信人: Deling (流浪歌手-爬爬死爬腰酸), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Fri Mar  9 15:19:00 2007), 转信

again, you don't get it, this has nothing to do with type safety.

【 在 LifeAsWater (烟水寒) 的大作中提到: 】
: In fact, when you define a delegate, you define a class.
: public delegate void Success();
: public delegate void Fail();
: void Test()
: {
: }
: I can intantiate a delegate Success with method Test.
: I also can intantiate a delegate Fail with method Test.
: From the OO point of view, Test is sucess or fail, contract is not clear
at
: all.
: ...................

--
__("<
\__/
  ^^
One small step for BSD, One giant step for PCs.



※ 来源:·BBS 未名空间站 mitbbs.com·[FROM: 24.16.]

 
les
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 46 ]

发信人: les (Walk the walk, talk the talk), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Fri Mar  9 15:35:10 2007)

hehe, we have a very good discussion here.
But it's not neccessary to focus too much on the specific word(Opaque,Safe
or Type safe).
I think people know about this tradeoff(Opaque/flexible) from day one.

Let's take a look what MSDN says:

Type Safety, Security, and Verifiability

Delegates are entirely opaque structures. There are no operations on
delegates except for a constructor, and methods to invoke the encapsulated
function. The code of even these methods is supplied by the runtime rather
than by the compiler. The runtime is able to guarantee the encapsulated
method has the correct signature. Since a delegate encapsulates an object
reference, it can rely on the metadata for this object to maintain types-
safety at runtime. That is the key to a delegate being typesafe and
verifiable.

A delegate can be considered a mechanism to indirectly invoke a method. Such
an invocation retains the semantics of the more conventional method
invocation, however, in that the method invocation is polymorphic, and it is
not possible to bypass any security demands on the actual method that gets
invoked. Security is not compromised when indirectly invoking methods
through delegates.
【 在 Deling (流浪歌手-爬爬死爬腰酸) 的大作中提到: 】
: again, you don't get it, this has nothing to do with type safety.
: at



--

※ 来源:·BBS 未名空间站 http://mitbbs.com·[FROM: 192.168.]

 
LifeAsWater
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 47 ]

发信人: LifeAsWater (烟水寒), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Fri Mar  9 16:13:04 2007)

Sure, delegate is a class and it must have type safty.
In concept, delegate is same as a method pointer, but delegate is a class.

What I mean that delegate is not type safe, it is that the delegate is a
general class and it only define the signature. Any method has the same
signature can instantiate the delegate. No contract there and no type there.
You still can say tradeoff.

Coin always has double side.

【 在 les (Walk the walk, talk the talk) 的大作中提到: ?: hehe, we have a
very good discussion here.
: But it's not neccessary to focus too much on the specific word(Opaque,Safe
: or Type safe).
: I think people know about this tradeoff(Opaque/flexible) from day one.
: Let's take a look what MSDN says:
: Type Safety, Security, and Verifiability
: Delegates are entirely opaque structures. There are no operations on
: delegates except for a constructor, and methods to invoke the encapsulated
: function. The code of even these methods is supplied by the runtime rather
: than by the compiler. The runtime is able to guarantee the encapsulated
: ...................



--

※ 来源:·BBS 未名空间站 http://mitbbs.com·[FROM: 65.223.]

 
Deling
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 48 ]

发信人: Deling (流浪歌手-爬爬死爬腰酸), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Fri Mar  9 16:21:27 2007), 转信


【 在 LifeAsWater (烟水寒) 的大作中提到: 】
: Sure, delegate is a class and it must have type safty.
: In concept, delegate is same as a method pointer, but delegate is a class.
: What I mean that delegate is not type safe, it is that the delegate is a
: general class and it only define the signature. Any method has the same
: signature can instantiate the delegate. No contract there and no type
there.
ft, this is exactly TYPE safe! as long as a program doesn't break the typing
rules of the type system, it's type safe.

and I still don't get your point, delegate or not, nothing can guarantee the
logic correctness, right? you can define an interface with method "fail",
but still you can't enfore the implementation to implement a fail rather
than a sucess.

:  You still can say tradeoff.
: Coin always has double side.
: 【 在 les (Walk the walk, talk the talk) 的大作中提到: ?: hehe, we have a
: very good discussion here.


--
__("<
\__/
  ^^
One small step for BSD, One giant step for PCs.



※ 来源:·BBS 未名空间站 mitbbs.com·[FROM: 24.16.]

 
LifeAsWater
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 49 ]

发信人: LifeAsWater (烟水寒), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Fri Mar  9 16:26:45 2007)

Are you coding a lot?

【 在 Deling (流浪歌手-爬爬死爬腰酸) 的大作中岬? 】
: there.
: ft, this is exactly TYPE safe! as long as a program doesn't break the
typing
:  rules of the type system, it's type safe.
: and I still don't get your point, delegate or not, nothing can guarantee
the
:  logic correctness, right? you can define an interface with method "fail",
: but still you can't enfore the implementation to implement a fail rather
: than a sucess.



--

※ 来源:·BBS 未名空间站 http://mitbbs.com·[FROM: 65.223.]

 
Deling
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 50 ]

发信人: Deling (流浪歌手-爬爬死爬腰酸), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Fri Mar  9 16:27:26 2007), 转信

yes I code a lot

【 在 LifeAsWater (烟水寒) 的大作中提到: 】
: Are you coding a lot?
: 【 在 Deling (流浪歌手-爬爬死爬腰酸) 的大作中岬? 】
: typing
: the


--
    ((`'-"``""-'`))
     )   -    -  (
    /   (o _ o)   \
    \    ( 0 )    /
    _'-.._'='_..-'_



※ 来源:·BBS 未名空间站 mitbbs.com·[FROM: 24.16.]

 
LifeAsWater
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 51 ]

发信人: LifeAsWater (烟水寒), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Fri Mar  9 16:38:08 2007)

My point is that interface explicitly define a contract and type.

When a method in a class implement an interface, you clearly know what is
the contract that the method commit to.

But in delegate case, for a method implementation, you never know what the
method comply to. It can be used in any delegate if the signature is match.


【 在 Deling (流浪歌手-爬爬死爬腰酸) 的大作中提到: 】
: yes I code a lot



--

※ 来源:·BBS 未名空间站 http://mitbbs.com·[FROM: 65.223.]

 
yiyayiyayo
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 52 ]

发信人: yiyayiyayo (Mera naam Itiaan hai), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Tue Mar 13 02:09:28 2007)


【 在 les (Walk the walk, talk the talk) 的大作中提到: 】
: 支持第二点。特别是没有3D library.
: 第一点不太care.不过前一阵子不是有新闻说Microsoft teams with novell to
: support mono project吗。

你做图形吗? 为什么要3D?


--

※ 来源:·BBS 未名空间站 http://mitbbs.com·[FROM: 76.199.]

 
SQL
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 53 ]

发信人: SQL (结构化的查询语言), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Sat Mar 17 00:25:22 2007)


功能还是太弱。


【 在 les (Walk the walk, talk the talk) 的大作中提到: 】
: 具体到某语言也行



--
===========================================================================
Disclaimer:
This posting is provided "AS IS" with no warranties, and confers no rights.
===========================================================================

※ 来源:·BBS 未名空间站 http://mitbbs.com·[FROM: 24.16.]

 
JasonKidd
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 54 ]

发信人: JasonKidd (贾轻侯), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Tue Apr 24 19:51:59 2007), 转信

exactly...


【 在 Deling (流浪歌手-爬爬死爬腰酸) 的大作中提到: 】

【 在 LifeAsWater (烟水寒) 的大作中提到: 】
: Sure, delegate is a class and it must have type safty.
: In concept, delegate is same as a method pointer, but delegate is a class.
: What I mean that delegate is not type safe, it is that the delegate is a
: general class and it only define the signature. Any method has the same
: signature can instantiate the delegate. No contract there and no type
there.
ft, this is exactly TYPE safe! as long as a program doesn't break the typing
rules of the type system, it's type safe.

and I still don't get your point, delegate or not, nothing can guarantee the
logic correctness, right? you can define an interface with method "fail",
but still you can't enfore the implementation to implement a fail rather
than a sucess.

:  You still can say tradeoff.
: Coin always has double side.
: 【 在 les (Walk the walk, talk the talk) 的大作中提到: ?: hehe, we have a
: very good discussion here.


--
__("<
\__/
  ^^
One small step for BSD, One giant step for PCs.






--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 74.71.]

 
hwd
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 55 ]

发信人: hwd (hwd), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Tue May  1 12:07:17 2007)


【 在 LifeAsWater (烟水寒) 的大作中提到: 】
: Compare delegate approach v.s. interface approach
: 1. delegate is not type safe. interface explicitly define the contract.
: 2. no easy way to group delegate. interface can have multiple method
defined
: .
: 3. delegate cannot support inheritance. interface supports inheritance and
: multiple inheritance.

: a delegate is a general class which invoke a predefine method at runtime
: using reflection. any method which has the signature can instantiate a
: delegate. it is type safe issue. 
: ...................

我觉得不要把delegate刻意看成是一个使用reflection的class,这样在系统设计和
delegate的使用中容易产生混淆。delegate提供了一个轻量级方式使用method
reference,这在Java中是没有的。使用delegate可以极大提高系统设计的灵活性,比
如动态method call,callback method等。
.NET开发语言是Strongly-typed,delegate只是一个method reference,无所谓type
safe. interface是属于更高层面的东西,是一个提供从设计层面控制开发代码质量的
辅助手段,这也是OO的一个精髓。我不理解为什么一定要牵强的把delegate和
interface联系在一起?

--

※ 来源:·BBS 未名空间站 海外: http://mitbbs.com 中国: http://mitbbs.cn·[FROM: 70.64.]

 
dfgqq
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 56 ]

发信人: dfgqq (布袋的演化), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Wed May  2 10:18:46 2007), 转信

delegate倒是不错胡东西
特别在异步通信 着方面

【 在 hwd (hwd) 的大作中提到: 】
: defined
: 我觉得不要把delegate刻意看成是一个使用reflection的class,这样在系统设计和
: delegate的使用中容易产生混淆。delegate提供了一个轻量级方式使用method
: reference,这在Java中是没有的。使用delegate可以极大提高系统设计的灵活性,比
: 如动态method call,callback method等。
: .NET开发语言是Strongly-typed,delegate只是一个method reference,无所谓type
: safe. interface是属于更高层面的东西,是一个提供从设计层面控制开发代码质量的
: 辅助手段,这也是OO的一个精髓。我不理解为什么一定要牵强的把delegate和
: interface联系在一起?



--

※ 来源:·BBS 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 124.226.]

 
IExplorer
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 57 ]

发信人: IExplorer (Powered by .COM), 信区: DotNet
标  题: Re: 你们最不喜欢.net的什么?
发信站: BBS 未名空间站 (Tue May 15 00:05:28 2007)

支持UNIX不就是CUT WINDOWS的市场吗. 老BILL精着呢..
【 在 les (Walk the walk, talk the talk) 的大作中提到: 】
: 对比一下java,是不是也要针对每一个Unix/Linux编写一个jvm呢?
: .net的问题是M$和厂商没有motivation to do that.



--

※ 来源:·WWW 未名空间站 海外: mitbbs.com 中国: mitbbs.cn·[FROM: 67.168.]

[首页][上页] [下页] [末页][分页:1 2 3 4 ]
[快速返回] [ 进入窗口里的风景讨论区] [返回顶部]
回复文章
标题:
内 容:

未名交友
将您的链接放在这儿

友情链接


 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996