有没有童鞋刷 leetcode 的必须把驼峰式命名改成下划线风格的?

2016-04-09 22:49:06 +08:00
 mantianyu

比如说这道题, 其中 Judge 系统给默认定义了如下 struct ListNode 类型.

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct ListNode* removeElements(struct ListNode* head, int val) {
    
}

作为一个坚守下划线命名风格的 c 程序员, 我是一定要写成下面这样的:

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */

#define remove_elements     removeElements
typedef struct ListNode          list_node;

list_node* remove_elements(list_node* head, int val) {
    
}

虽然好像变量名字长点的话确实没有驼峰式好看....

3148 次点击
所在节点    程序员
12 条回复
jmc891205
2016-04-09 22:52:53 +08:00
哈哈 这样不是还有两个驼峰式的
强迫症是病啊大兄弟!
Vernsu
2016-04-09 23:09:34 +08:00
注释掉的也是驼峰啊
KiriGiri
2016-04-09 23:21:27 +08:00
不喜欢下划线,会弄的名字很长,而且下划线在右上角,用手按过去很麻烦。
mantianyu
2016-04-09 23:45:00 +08:00
@jmc891205 本来也应该不会有人要求类型定义和宏定义里的东西也必须遵守某种风格呀

@Vernsu 注释马块懒得改了。。

@KiriGiri 长确实是真的。。有时候确实我也觉得不好看。。。
SoloCompany
2016-04-10 06:07:05 +08:00
大小写敏感的系统搞什么鬼下划线
只有数据库设计这些为了能适应大小写不区分的系统的才会考虑使用下划线
dxwwym
2016-04-10 07:25:21 +08:00
驼峰第一个字母也大写?
xpol
2016-04-10 09:20:43 +08:00
@dxwwym Wikipedia:The first letter of a camel case compound word may or may not be capitalized, and there is no real consensus on whether the term camel case generally implies an uppercase or lowercase first letter.[2][3][4] For clarity, this article calls the two alternatives upper camel case and lower camel case. Some people and organizations use the term camel case only for lower camel case.
ColinWang
2016-04-10 09:51:41 +08:00
@dxwwym 类名第一个也大写,其他的方法名,变量名第一个小写。
allan888
2016-04-10 10:03:41 +08:00
https://github.com/jieaozhu/leetcode
再安利一波我目前的解答,都是 java 的。
之前刷完的计划还是没实现,目前有一百来题了,正在努力填坑。
allan888
2016-04-10 10:04:37 +08:00
@allan888 话说因为我没刷完,所以 fork 我的我都好心的不定期给发了 pull request 。。。
然而一个接受 pr 的都没有!!
mantianyu
2016-04-10 10:10:33 +08:00
@allan888 共勉~ 我也在努力填坑中
SuperFashi
2016-04-10 15:53:41 +08:00
奇怪, C/C++难道不是标准驼峰吗,反正我是一直驼峰 hhhh

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/269854

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX