模板对象的命名约定
我们有一组模板文件,用户可以复制并稍后修改。我们对“名称”字段有一个唯一的约束,因此当某个用户复制模板文件(例如“文件 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将复制的日期添加到文件名中。将精度调整到最不可能引起问题的时间范围。
另外,我更喜欢副本的后缀而不是前缀,以便副本存储在原始副本旁边。
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.
Also, I prefer suffixes to prefixes for copies so that the copy is stored next to the original.
与win7的资源管理器在同一文件夹中拖放复制文件时执行的操作类似:
Do the something similar what the explorer of win7 does when you drag-and-drop-copy a file within the same folder: