【发布时间】:2019-06-11 08:49:17
【问题描述】:
最近经常看到如下代码(这个例子取自 Symfony):
protected function execute(InputInterface $input, OutputInterface $output)
{
throw new LogicException('You must override the execute() method in the concrete command class.');
}
与仅将方法标记为 abstract 相比,这里有什么好处?
对...有什么好处
- ...库作者?
- ...图书馆用户?
我已经为 Java (Faking abstract methods using exceptions in Java) 找到了一个类似的问题,但它的答案不是很有帮助,因为它的答案是明确的猜测和意见。
【问题讨论】:
-
Some ideas from Software Engineering (C#)。归结为“永远不应该投入生产”,但在开发过程中作为一个危险信号,表明缺少某些东西。
标签: php symfony exception abstract