douruhu4282 2011-04-27 21:35
浏览 10
已采纳

PHP命名空间组织,命名

I am facing the following problem :

  • I have a namespace Exception\*, which contains several types of exceptions.

  • I have a namespace Exception\User\*, which contains a specific kind of exceptions (Forbidden, LoggedOut...).

Where do I put the User base exception class, extended by Forbidden and LoggedOut :

  • Exception\User, i.e. in the Exception\* namespace (better full name) ?
  • Exception\User\User, i.e. in the Exception\User\* namespace (more consistent) ?
  • Exception\User\Exception, i.e. I rename it to be the "base" exception of the Exception\User\* namespace (weird) ?

NB : the User exception class is not abstract.

Precision : I've used an example with exceptions, this is just an example. I am really wondering about where to put/how to name a base class in a namespace tree.

Thanks if you can help me !

  • 写回答

2条回答 默认 最新

  • douping1581 2011-06-07 20:18
    关注
    Exception\User
    Exception\User\Forbidden
    Exception\User\LoggedOut
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM