我对类名的选择受到 SVN/域驱动设计的 Windows XP 最大路径长度问题的阻碍 - 任何解决方案
我正在使用 PHP 5.2 制作一个网站,
我喜欢为我的类提供明确的名称,
我还有一个约定,即“文件的路径和名称”与“类的名称”匹配,
的类
因此名为: ABCSiteCore_Ctrlrs_DataTransfer_ImportMergeController
将坐下在我的 svn 工作副本中:
C:\_my\websrv\ABCCoUkHosting2\webserve\my_library\vendor\ABCSiteCore-6-2\ABCSiteCore\Ctrlrs\DataTransfer\ImportMergeController.php
我发现命名约定让我可以更好地了解我的代码库,从而更好地理解并减少复杂性的感觉。
不幸的是,我的 Windows XP PC 上似乎有最大路径长度。当我尝试将 Subversion 文件检出到我的工作副本中时,它似乎会引起问题。
如果路径太长,我无法签出 - 签出失败。
所以我发现自己花了很长时间才想到一个领域概念的名称。
我可能想将一个类命名为“通知服务” - 但我最终将其称为“NtfctnSrvce”之类的名称。当我尝试创建规范类时,它也会引起问题。
比如说,我希望有一个用显式名称调用的规范类,比如:
$hasBeenNotifiedSpec = new ABCSiteCore_Model_MssgSys_Rules_Customers_HasCustomerBeenSentNotificationOfOnlineTransactionPaymentByEmail($notificationLog);
if($hasBeenNotifiedSpec->isSatisfiedBy($customer))
{
...do something
通过使用我的文件到类名命名约定,我可以简单地使用 Windows 资源管理器来很好地了解该类的用途,它在模型/视图/控制器模式中的位置/角色等。
ABCSiteCore\
Model\
MssgSys\
Rules\
Customer\
HasCustomerBeenSentNotificationOfOnlineTransactionPaymentByEmail.php
每当我想到域概念的名称时,我都会养成将潜在路径长度粘贴到“路径长度检查器”中的习惯>' 看看我是否可以使用它 - 它只是我的工作笔记维基中的一段预先格式化的文本:
如您所见。不幸的是,类名已经接近极限。
C:\_my\websrv\ABCCoUkHosting2\webserve\my_library\vendor\ABCSiteCore-6-2\ABCSiteCore\Model\MssgSys\Rules\Customer\hasCustomerBeenSentNotificationOfOnlineTransactionPaymentByEmail.php
-------------------------------------------------------------------------------------------------------------------------------------------------------------------script path length danger zone------->|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------max path length danger zone (inclusive .svn folder)------->|
C:\_my\websrv\ABCCoUkHosting2\webserve\my_library\vendor\ABCSiteCore-6-2\ABCSiteCore\Model\MssgSys\Rules\Customer\.svn\text-base\hasCustomerBeenSentNotificationOfOnlineTransactionPaymentByEmail.php.svn-base
由于这些路径长度限制,我倾向于为实体选择不最适合域模型通用语言的名称。这有时会导致对系统如何工作的误解,造成混乱并增加复杂性 - 使开发变得更加困难。
所以:
- 我该如何解决这个问题?
- 这是可以解决的还是这只是一个 我们所面临的那些实际限制 一切只需要处理?
- 这只是PC的事情吗?也许是时候切换到 Mac 或 Linux 了。
I'm using PHP 5.2 to make a website
I like to have explicit names for my classes
I also have a convention saying 'the path and name of a file' match the 'name of the class'
So a class called:
ABCSiteCore_Ctrlrs_DataTransfer_ImportMergeController
would sit in my svn working copy at:
C:\_my\websrv\ABCCoUkHosting2\webserve\my_library\vendor\ABCSiteCore-6-2\ABCSiteCore\Ctrlrs\DataTransfer\ImportMergeController.php
I find the naming convention gives me a better view of my code base, leading to better understanding and reducing the feeling of complexity.
Unfortunately there seems to be a max path length on my Windows XP PC. It seems to cause problems when I try to checkout Subversion files into my working copy.
If the path is too long, I can't check it out - the checkout fails.
So I find myself taking ages just to think of a name for a domain concept.
I might want to name a class "notification service" - but I end up calling it something like "NtfctnSrvce". It also cause problems when I try to create a specification class.
say, for example i'd love to have a spec class called with an explicit name,say:
$hasBeenNotifiedSpec = new ABCSiteCore_Model_MssgSys_Rules_Customers_HasCustomerBeenSentNotificationOfOnlineTransactionPaymentByEmail($notificationLog);
if($hasBeenNotifiedSpec->isSatisfiedBy($customer))
{
...do something
By using my file-to-class-name naming convention, I can simply use Windows Explorer to get a good idea of what the class does, its place /role in the Model/View/Controller pattern etc.
ABCSiteCore\
Model\
MssgSys\
Rules\
Customer\
HasCustomerBeenSentNotificationOfOnlineTransactionPaymentByEmail.php
Whenever i think of name for a domain concept, I've got into the habit of pasting the potential path length into a 'path length checker' to see if i can use it - its just a peice of pre-formatted text in my working-notes-wiki:
As you can see. Unfortunately that class name is getting close to the limits
C:\_my\websrv\ABCCoUkHosting2\webserve\my_library\vendor\ABCSiteCore-6-2\ABCSiteCore\Model\MssgSys\Rules\Customer\hasCustomerBeenSentNotificationOfOnlineTransactionPaymentByEmail.php
-------------------------------------------------------------------------------------------------------------------------------------------------------------------script path length danger zone------->|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------max path length danger zone (inclusive .svn folder)------->|
C:\_my\websrv\ABCCoUkHosting2\webserve\my_library\vendor\ABCSiteCore-6-2\ABCSiteCore\Model\MssgSys\Rules\Customer\.svn\text-base\hasCustomerBeenSentNotificationOfOnlineTransactionPaymentByEmail.php.svn-base
Because of these path length restrictions, I tend to choose names for my entities that are not the best fit to the ubiquitous language of my domain model. This, can sometimes lead to misconceptions about how the system works, causes confusions and adds to the complexity - making development harder.
so :
- How can I solve this issue?
- is it solvable or is this just one one
those practical constraints that we
all just have to deal with? - is this just a PC thing? It might be time to switch to Mac or Linux.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是一些可能对您有所帮助的抽象建议;是的,可以切换操作系统,但不是你想的那样 - 获取 virtualbox 并加载 Linux 版本(ubuntu 很好)并且快速+良好支持)然后使用该虚拟操作系统作为您的开发操作系统 - 这样您就可以两全其美,当您完成工作时,您只需关闭虚拟机(如果您愿意,可以保存它的状态)并拥有一个漂亮干净的电脑可以做你想做的事。
好处几乎是无限的,例如我有几个虚拟机,我可以随时加载,有些是测试设置,有些是镜像 Web 服务器设置,我什至有不同版本的 Windows(例如带有 IE6 的旧 XP)来测试浏览器错误。
令人惊讶的是,我实际上发现我的机器使用 virtualbox 运行更快;请不要让设置和运行的时间让您担心,因为 virtualbox 非常快,您会发现虚拟机的加载速度比主操作系统快得多。
还有许多其他好处,但总的来说,这是一次非常解放的体验:)
Here's some abstract advice which may help you; yes switch operating systems, but not how you think - get virtualbox and load in a version of linux (ubuntu's nice and quick + well supported) then use that virtual os as your development os - this way you get the best of both worlds, and when you're finished working you simply close the virtual machine (saving it's state if you like) and have a nice clean pc to do what you want with.
The benefits are almost unlimited, for instance I have several virtual machines which I can load up whenever, some are testing setups, some mirror web server setups, I even have different editions of windows (such as an old XP with IE6) to test out browser bugs.
Surprisingly, I actually find my machine runs quicker using virtualbox; and please don't let the time to setup and run things worry you, as virtualbox is extremely quick, and you'll find your virtual machines load much faster than your primary os.
There are many other benefits which come with, but over all it's a very liberating experience :)
原因实际上在这里提到: http://svn.haxx.se/用户/archive-2005-02/1088.shtml
如果你问我的话,对于所谓操作系统的东西来说是相当尴尬的。解决方法:使用 Tortoise SVN。但另一方面,我不喜欢乌龟,因为它太慢了。
The cause is actually mentioned here: http://svn.haxx.se/users/archive-2005-02/1088.shtml
Pretty embarrassing for something that is called an OS, if you ask me. Workaround: Use Tortoise SVN. However I do not like Tortoise on the other hand since it's so slow.