Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

考虑尽量使用 camelCase/snake_case 而不是 Lisp-case #1

Open
hozuki opened this issue May 22, 2018 · 1 comment
Open

考虑尽量使用 camelCase/snake_case 而不是 Lisp-case #1

hozuki opened this issue May 22, 2018 · 1 comment
Labels
accepted Accepted suggestion. To be applied.

Comments

@hozuki
Copy link
Member

hozuki commented May 22, 2018

例如 InteractionHints 中的 touch-policy(键)、hit-target(值)。

尤其是键的命名,更贴近 POJO 明显会带来一些好处:

  1. 让 JavaScript/TypeScript 代码分析更准确。使用 Lisp-case 意味着需要硬编码(更容易出错),或者专门用一个 enum class 来存储映射关系。使用 camelCase 可以直接使用 . 访问,查找用例、TS 的编译查错等等也会更方便。
  2. 方便包括参考实现在内,不同语言的实现。由于大多数语言都不支持 Lisp-case 的符号名,所以实体映射时需要指定额外的信息。虽然许多现代 JSON 框架都支持名称映射,但对于不支持元数据(狭义的元数据)的语言来说仍然是噩梦,比如 JavaScript、C/C++,这时候又要面临上面的硬编码问题。

对于值的倒没有键的那么必要,不过仍然建议指定一个建议标准。

@jabbany
Copy link
Member

jabbany commented May 22, 2018

确实。。。最近一直在写ide(想看看实际的话会怎么work),一直在忽视文档。
同意这个会比较好。。。

(想起了为什么有一些是 - 。。。好像是因为一定程度沿用 CSS)

@jabbany jabbany added the accepted Accepted suggestion. To be applied. label May 22, 2018
@jabbany jabbany added this to the Full 0.1.0 Specifications milestone May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Accepted suggestion. To be applied.
Projects
None yet
Development

No branches or pull requests

2 participants