模板对象的命名约定

发布于 2024-10-09 12:44:03 字数 253 浏览 0 评论 0原文

我们有一组模板文件,用户可以复制并稍后修改。我们对“名称”字段有一个唯一的约束,因此当某个用户复制模板文件(例如“文件 1”)时,我们将其添加为“文件 1 的副本”,如果他复制模板文件(例如“文件 2”),我们将其添加为“文件 2”作为“文件 2 的副本”(即,当我们复制这些文件时,我们添加适当的前缀),这样我们就不会违反唯一约束。

但是,如果他再次添加相同的文件“文件 1”,我们会遇到唯一的约束冲突错误,我应该遵循什么样的命名约定,以便我可以使其对最终用户来说足够直观。

We have a set of template files which can be copied by users and modified later. We have a unique constraint on the "name" field, so when some user copies a template file say "File 1" we add it as "Copy of File 1" and if he copies a template file say "File 2" we add it as "Copy of File 2" (i.e. we add an appropriate prefix, when we copy these files) so we don't violate the unique constraint.

But if he adds the same file "File 1" again we run into a unique constraint violation error, what kind of naming convention should I follow, so that I can make it intuitive enough for the end user.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

本宫微胖 2024-10-16 12:44:03

您可以将复制的日期添加到文件名中。将精度调整到最不可能引起问题的时间范围。

e.g. File1 -> File 1 - Copy 2010-12-29 0017

另外,我更喜欢副本的后缀而不是前缀,以便副本存储在原始副本旁边。

You could add the date of when the copy was made to the filename. Adjust the precision to the time frame least likely to cause a problem.

e.g. File1 -> File 1 - Copy 2010-12-29 0017

Also, I prefer suffixes to prefixes for copies so that the copy is stored next to the original.

梦在深巷 2024-10-16 12:44:03

与win7的资源管理器在同一文件夹中拖放复制文件时执行的操作类似:

index.html
index - Copy.html 
index - Copy (2).html
index - Copy (3).html 

Do the something similar what the explorer of win7 does when you drag-and-drop-copy a file within the same folder:

index.html
index - Copy.html 
index - Copy (2).html
index - Copy (3).html 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文