发信人: LifeAsWater (烟水寒), 信区: DotNet
标 题: Re: 你们最不喜欢.net的什么？
发信站: BBS 未名空间站 (Fri Mar 9 14:36:24 2007)
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
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.
No one is bad if it does not be compared to other.
【 在 Deling (流浪歌手-爬爬死爬腰酸) 的大作中提到: 】
: This has NOTHING to do with type safety. Don't mix up type with semantics.
: Delegates are not as useful compared to general lamba abstraction (where
: delegates rooted) because they are not treated as values as functional
: languages do. That doesn't neccessarily mean they are a bad thing.
※ 来源:·BBS 未名空间站 http://mitbbs.com·[FROM: 65.223.]