网络资源中的驼峰案例

发布于 2024-10-15 01:09:53 字数 404 浏览 0 评论 0原文

您对使用驼峰式命名法来存储网络资源有何看法?

我有 Java 背景,驼峰式大小写是我的第二天性,但在命名 Web 资源(例如 html、css、javascript)时,驼峰式大小写仍然感觉不正确。

(例如 http://localhost/application/editUserForm.htmlhttp://localhost/application/edit/user/form.html)

欢迎任何意见、建议!

What is you opinion on using camel case for web resources?

I am coming from a Java background where camel case is second nature, but still when naming web resources, such as html, css, javascript camel case does not feel right.

(e.g. http://localhost/application/editUserForm.html vs http://localhost/application/edit/user/form.html)

Any comments, suggestions are welcome!

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

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

发布评论

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

评论(4

云归处 2024-10-22 01:09:53

命名方案的主要考虑因素是对 SEO 的影响。根据我的理解,谷歌(大概还有其他引擎)可以“读取”单个字符串中的合并单词,因此驼峰式大小写应该没问题,就像单个不区分大小写的字符串一样。对于能力较差的蜘蛛来说,使用重写按目录拆分方案会更清晰。 Google 给出的一条建议是使用连字符 (-) 而不是下划线 (_),但这与此无关。

如果您希望真人必须输入完整的地址,那么使用易于阅读的内容将是一个好处,可以最大限度地减少错误。

The main consideration on naming schemes would be impact on SEO. From my understanding, Google (and presumably other engines) can 'read' amalgamated words in a single string, so camel case should be OK, as would a single case-insensitive string. Splitting the scheme by directory using rewrites would be clearer for less capable spiders. One piece of advice Google give is to use hyphens (-) rather than underscores (_), but that's not relevant here.

If you expect a real person to ever have to type the full address, using something easy to read would be a bonus in order to minimise error.

旧城空念 2024-10-22 01:09:53

我不认为这样的命名有什么问题。

我个人的偏好是使用 - 命名 Web 资源,例如 edit-user.jsp。我认为这更多是个人品味的问题。我不喜欢_- 可以更轻松地在浏览器地址栏中直观地查找单独的单词(至少对我来说)。据我所知 - 很常见。

I don't find anything wrong with such naming.

My personal preference is to name web resources with -, like edit-user.jsp. I think it's more question of personal taste. I don't like _. - makes easier to visually find separate words in browser address bar (at least for me). And as far as I saw - is pretty common.

乖乖公主 2024-10-22 01:09:53

如果您在 Windows 环境上部署站点(无论是用于开发还是托管),则可能会因 2 个外壳不同的相同资源而出现问题。

但如果你避免像这样的“双重”文件名,它或多或少都会有味道。

像这样的命名方案 http://localhost/application/edit/user/form.htm 确实可以更好地显示单独的单词,并且可能更容易解析为与“用户”有关的内容。

It might open the door to problems with 2 the same resources that differ in casing, if you are deploying your site on a windows environment (either for development or hosting).

But if you avoid 'double' filenames like that it's more or less taste.

A naming-scheme like this http://localhost/application/edit/user/form.htm does show the seperate words better, and might be easier to parse as something to do with "user".

〗斷ホ乔殘χμё〖 2024-10-22 01:09:53

我觉得驼色肠衣不太吸引人。虽然它是 Java 的约定,我们在编写 java 时应该遵循它,但在命名其他东西时我们不必遵循它。

并不是我们觉得在每两个单词之间插入一个分隔符很繁琐,而是下划线确实很难打字,它需要两个小指才能伸展很远。不幸的是,下划线在标识符中受到语言设计者的青睐。

无论谁发明了下一个编程语言,请使用“/”作为名称空间分隔符,并使用“.”作为单词分隔符,所以

java.beans.beancontext.BeanContext.getResourceAsStream()

我们

java/beans/bean.context/Bean.Context/get.resource.as.stream()

不必等待...“/”已经用于除法。没关系。

I don't find camel casing very appealing. While it is the convention for Java and we should follow it when doing java, we don't have to when naming other stuff.

It's not that we find it tedious inserting a separator between every two words, but the underscore is really hard to type, it requires two pinky fingers to stretch very far. Unfortunately underscore is favored by language designers in identifiers.

Whoever invent the next programming language, please use '/' as name space separator, and '.' as word separator, so instead of

java.beans.beancontext.BeanContext.getResourceAsStream()

we have

java/beans/bean.context/Bean.Context/get.resource.as.stream()

wait... '/' is already used for division. never mind.

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