Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Why change the spelling of functions  (Read 7698 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Why change the spelling of functions
« Reply #15 on: April 03, 2013, 04:22:52 pm »
Quote
Strange, because underscores are easier on the eyes than helloJavaWorld (compare with hello_java_world, I can better separate the words).
By separating the words inside identifiers more easily, you make separating the identifiers themselves harder. In other words, it's more important to see the space between identifiers rather than the space inside them. By using underscores, which look like spaces, the limit between words-inside-identifiers and identifiers themselves gets thiner, which makes the code harder to decode.

Which one is the easiest to read?

my object.the member = some strange value;

myobject.themember = somestrangevalue;

For a book, the first one. For a source code, definitely the second one. Because we don't care if the object name or its member is made of several words or just one -- for the programmer it's still a single identifier, and it must be seen as such ;)

I think it's the most common complain about this naming convention.
Laurent Gomila - SFML developer

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Why change the spelling of functions
« Reply #16 on: April 03, 2013, 06:57:12 pm »
Personally I don't care what the naming convention is, but in reality there will always be different conventions. Each have their own "pros" and "cons" and all the while different people will prefer one convention over the other.

But in the end there is no way to satisfy everyone. So in your own code use the convention you want and if you use a library that uses a convention you don't like then either deal with it, write your own wrapper around it, or choose an alternative library.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Why change the spelling of functions
« Reply #17 on: April 03, 2013, 07:38:02 pm »
Quote
Which one is the easiest to read?
Honestly? The first one, both for book- and source reading. And if something's good readable in a book, then it should be great in source too. Or do you want to tell me that you don't want to read source code like a book? ;)

I agree to zsbzsb. I also don't really care what naming conventions libraries I use are using. As long as it's not hElLoWoRlD(), but I haven't seen that so far.

Haze

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Github Profile
Re: Why change the spelling of functions
« Reply #18 on: April 03, 2013, 08:05:24 pm »
Quote
what_the_hell("?!?!?");[...]And now Tank comes out with his hello_stefan_convetion
I assume you don't like it? I even don't get why people use different styles for C++. In other languages people tend to stick to the naming conventions the standard lib uses, at least in Python, JavaScript, Ruby and similar languages.
Don't worry, I use the superior_cpp_naming_convention when I code in Java or JS in retaliation.

I'm also very surprised people can actually find it less readable, as I precisely prefer this naming convention for its readability.
However it makes identifiers a bit longer (thus, longer lines).

FRex

  • Hero Member
  • *****
  • Posts: 1846
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Why change the spelling of functions
« Reply #19 on: April 03, 2013, 08:41:47 pm »
Quote
I assume you don't like it?
I just didn't ever see anyone use hello_stefan while not joking or messing around except boost(glorified std) and std(if they changed it, they'd break so much code it's not even funny).
Quote
I even don't get why people use different styles for C++.
Because c++ doesn't make programer brainless? ;D
Quote
As long as it's not hElLoWoRlD(), but I haven't seen that so far.
This would make great april fools joke from Laurent.
#include <SfMl/gRaPhiCs.hP+>
int main()
{
sF::ReNdErWiNdOw app(sF::ViDeOmOdE(600,480),"Hello Laurent");
while(app.IsOpEn())
{
sF::EvEnT eve;
while(app.pOlLeVeNt(eve)) if(eve.tYpE==sF::EvEnT::cLoSeD) app.cLoSe();
app.cLeAr();
app.dIsPlAy();
}

}
This is hElLoLaUrEnT convention.
Back to C++ gamedev with SFML in May 2023

Cornstalks

  • Full Member
  • ***
  • Posts: 180
    • View Profile
    • My Website
Re: Why change the spelling of functions
« Reply #20 on: April 03, 2013, 09:57:22 pm »
Not that I'm super relevant, but I use camelCase primarily because it makes it easy to differentiate between types and objects. I don't really hate the underscore convention (and sometimes I use it myself, depending on the project), but I like the "rule" that if the first letter is a capital, it's a class/type, whereas if the first letter is not a capital, it's not a class/type. The standard naming convention used in C++ doesn't give you any kind of indication on that.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Why change the spelling of functions
« Reply #21 on: April 03, 2013, 11:53:23 pm »
I have to admit that I use ThisOne for types.. Shame on me, but I also like to immediately see what's a type and what's a variable/CONSTANT.

MorleyDev

  • Full Member
  • ***
  • Posts: 219
  • "It is not enough for code to work."
    • View Profile
    • http://www.morleydev.co.uk/
Re: Why change the spelling of functions
« Reply #22 on: April 04, 2013, 08:47:07 pm »
The words themselves are as readable in either, obviously, but many prefer camelCase because it makes it easier to differentiate between variables, classes and functions with camelCase (of both the Java and C# variates). So to them, camelCase means less writing and less thought for the same functionality.

Can't say I disagree. Of course you shouldn't take that argument too far, otherwise you end up with the pointless Hungarian notation...
« Last Edit: April 04, 2013, 08:48:38 pm by MorleyDev »
UnitTest11 - A unit testing library in C++ written to take advantage of C++11.

All code is guilty until proven innocent, unworthy until tested, and pointless without singular and well-defined purpose.

 

anything