On the downside, multiple interfaces incur a loss of static type safety because interfaces are selected only at runtime, which makes the system more vulnerable to latent bugs that can escape testing.
多接口的缺点是,它招致了静态类型安全性的损失,因为接口只在运行时被选择,这使得系统更容易受到潜伏错误的伤害,即那些逃过测试的错误。
This gives the expressiveness of duck-typing with the safety of static type-checking.
这既给予了动态类型的表达能力又保留了静态类型检查的安全。
Oftentimes this will be no loss, because the object wouldn't have a static type anyway, in other cases it is a tradeoff between brevity and safety.
有的时候这不会有任何损失,因为对象根本不具有静态类型,而且他情况下必须在简洁和安全之间进行权衡。
应用推荐