图书馆之间的区别? (目录结构)
因此,这里是我当前正在处理的 Web 应用程序上的目录结构的快速摘录:
/app
/libraries
User_Input.php
Database.php
InvoiceHandler.php
您认为 InvoiceHandler
在这个集合中有点奇怪吗?我当然知道。
直到最近,我还忽略了区分事实上的库(实际上是我的应用程序和其他服务(例如持久存储)之间的中间层)和我自己编写的包含自定义逻辑的代码类的需要。我的应用程序(例如本例中的 Invoice_Handler)。
但随着我的应用程序的增长,这会造成越来越混乱。到目前为止,我还没有看到任何关于这方面的好的例子,而且我没有足够的经验来自己得出结论:
对于这两个明确且明显不同的类别的分离,惯例和常识有何看法?
So, here's a quick extract of the directory structure on a web application that I am working on currently:
/app
/libraries
User_Input.php
Database.php
InvoiceHandler.php
Do you think that the InvoiceHandler
is a bit odd in this collection? I sure do.
Until recently, I have ignored the need to distinguish between de-facto libraries that actually are the middle-layer between my application and other services (such as a Persistent storage) and the classes of code that I have written myself that contains custom logic for my application (such as the Invoice_Handler in this case).
But as my application grows, this creates more and more of a mess. I haven't seen any good examples on this as of today and I have not enough experience to come to a conclusion by myself:
What does conventions and common sense say on separation of these two definite and so clearly different sort of classes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用以下结构:
You can use the following structure:
这个问题有点模糊,显示的示例文件名并没有真正解释它们。然而,我会说你需要将你的课程组合成一个有意义的结构。
我使用的类与您的类有很大不同(至少我认为是),但您可以清楚地看到它们被分组为逻辑结构。
This question is a bit vague, and the example filenames shown don't really explain much about them. I will however say that you need to group your classes together into a structure that makes sense.
The classes I've used are vastly different (at least I think they are) from yours, but you can clearly see they are grouped into a logical structure.
我最终根据库包含的抽象级别来分离它们。为了寻找更好的高级抽象名称,我使用了类别名称
services
来表示这些名称,并使用libraries
来保留低级抽象类。IE。 :
I ended up separating my libraries depending on what level of abstraction they contained. In search of a better name of high-level abstraction, I used the category name
services
for these and retained withlibraries
for low-level abstraction classes.Ie. :