TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 25 Jan 2017 09:01 AM |
Hi all, I have a small question which may seem trivial, but it has to do with, yet again, about the differences between camelCase and PascalCase. Today in my CS I class a student asked about the reason why some of her variables had uppercase letters in them, i.e, pizzaSize, for example. She more or less said "because that's how c++ works with variables" and I immediately gave the counter argument that variable names are merely just a preference. She said that "for me" I had no choice and I had to use camelCase. I laughed to myself. How could she possibly "force" us to use only one way of writing variables. She said she wrote up a 30 page report on standard programming practices and that her students should follow them. Now I know camelCase is for the most part an industry standard and I'm sure she is just trying to get us used to that fact, and I myself have a preference to use camelCase, but I see no wrong in using PascalCase. Surely I am over complicating this issue, but I digress. What are your thoughts and opinions on the matter between both forms of writing variables? What are best practices? Does it truly make any difference at all?
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 25 Jan 2017 09:02 AM |
warning: tl;dr
Basically, why would she choose camelCase over PascalCase
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
|
| 25 Jan 2017 09:07 AM |
| I usually use PascalCase because that's how our teacher taught us, and that is also the reason why I prefer it. The only real reason why she tries to make others use camelCase is for the reason you already mentioned, it's almost an industry standard and the differences between coding styles often cause confusion in large projects (I had to deal with snake_case, and it was a horror). |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 25 Jan 2017 09:10 AM |
Oh god, I cannot begin to imagine your pain.
|
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 25 Jan 2017 09:11 AM |
looking at the docs, the C++ API uses snake_case how can she stand something like that |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
Rick_EU
|
  |
| Joined: 05 Mar 2013 |
| Total Posts: 5093 |
|
|
| 25 Jan 2017 09:39 AM |
@Time can u tell me how to add particles on a character?
[̲̅$̲̅(̲̅5)̲̅$̲̅] $$ Bling $$ [̲̅$̲̅(̲̅5)̲̅$̲̅] |
|
|
| Report Abuse |
|
|
Kutoru
|
  |
| Joined: 22 May 2016 |
| Total Posts: 288 |
|
|
| 25 Jan 2017 09:54 AM |
| for readability I prefer camelCase |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 25 Jan 2017 10:07 AM |
| Even though it's preference, programmers are expected to be able to read and alter the code of others. The more consistent simple things like this and other things are, the easier and faster it is to do so. |
|
|
| Report Abuse |
|
|
RogueMage
|
  |
| Joined: 28 Jan 2012 |
| Total Posts: 1235 |
|
|
| 25 Jan 2017 10:18 AM |
| I think it's important to follow common practices, as you have to check others' code and have others check yours. Especially in OOP languages like Java, C++, and yes, Lua, all classes are in PascalCase while variable names are in camelCase (aside from class constants and the sort). I mean, I'm not in a college CS class but I am taking APCS in High School right now and this is what they're teaching us. We have volunteers from the industry come and teach us, aside from the district's given teacher, so I think it's smart to listen to what they say. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 25 Jan 2017 01:06 PM |
Thanks for the input. I can see the importance now of following these practices.
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 25 Jan 2017 01:09 PM |
I wish snake_case was more popular, I would use it :)
This is odd because my roommate's CS teacher insists they use Pascal and he is bothered by the fact that I use both camelCase and Pascal when I do Lua here.
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 25 Jan 2017 01:11 PM |
Like it was said above, sometimes it depends on what type of variable it is. I use pascal for functions and constants, and camel for other variables
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 25 Jan 2017 01:12 PM |
IMO: It might be industry standard, but at the end of the day if whoever reviews your code is really worth their salt then they shouldn't be triggered by your choice of case.
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 25 Jan 2017 01:13 PM |
I do the same thing actually :>
What's it called when someone just uses caps to name things? UPPERCASE? haha
|
|
|
| Report Abuse |
|
|
Rerumu
|
  |
| Joined: 11 Oct 2014 |
| Total Posts: 950 |
|
|
| 25 Jan 2017 01:27 PM |
Standards are disgusting. There are no real pros and cons of using one over another besides readability. Do what YOU can read best, if you are sharing code you may want to have it different but it's not like it matters, everyone has their own style.
I was never taught a style as I'm self taught but just gravitate to PascalCase by default. |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2017 02:07 PM |
Usually use PascalCase in Lua and camelCase in any other language, personal preference. |
|
|
| Report Abuse |
|
|
AxonMega
|
  |
| Joined: 29 Aug 2014 |
| Total Posts: 2403 |
|
|
| 25 Jan 2017 02:16 PM |
| I prefer camelCase for standard variables and PascalCase for modules (in Lua they're not really modules but you get the idea). |
|
|
| Report Abuse |
|
|
|
| 25 Jan 2017 02:22 PM |
| Camel Case, Pascal Case, and Snake Case are all for inferior minds. 1 N4M3 M7 \/4R143L35 1|\| L337, F0R 1|\|574NC3: M7V4R14BL3 |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 25 Jan 2017 02:35 PM |
| I usually use camelcase for function names, and pascal for most other things. I sometimes revise this personal standard mid-project and then end up hating myself. |
|
|
| Report Abuse |
|
|
Froast
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 3134 |
|
|
| 25 Jan 2017 02:48 PM |
there is no argument for it not being preference, but if she is your teacher than you should listen to her and just keep it consistent even in a real job your boss could force you to use a specific standard so that all code is consistent |
|
|
| Report Abuse |
|
|