Code: Select all
void func();
void myFunc();
Code: Select all
void func();
void my_func();
//OR
void Func();
void MyFunc();
Moderator: Coders of Rage
Code: Select all
void func();
void myFunc();
Code: Select all
void func();
void my_func();
//OR
void Func();
void MyFunc();
For further detail, look at the page, it contains about 100 conventions whose breakdown would've taken pretty long :D6 - Names representing methods or functions must be verbs and written in mixed case starting with lower case.[...]Code: Select all
getName(); computeTotalWidth();
9. Abbreviations and acronyms must not be uppercase when used as name.Code: Select all
exportHtmlSource(); // NOT: exportHTMLSource(); openDvdPlayer(); // NOT: openDVDPlayer();
From what I understand it's a personal choice. The first method is called lower camel case and the second upper camel case. Although it is a thing of preference, generally, I see lower camel case used for global functions, and upper camel case used for methods of a class.ajtgarber wrote:I remember reading somewhere that the convention for naming functions is to leave the first word uncapitalized, then the following words would be capitalized like:but I've seen in various places functions like this:Code: Select all
void func(); void myFunc();
What is the convention for naming functions?Code: Select all
void func(); void my_func(); //OR void Func(); void MyFunc();
Code: Select all
void MyFunc();
Code: Select all
void myFunc();
Code: Select all
class MyClass {};
Code: Select all
class MyClass { void MyMethod(); };
Code: Select all
class MyClass { void myMethod(); };
Code: Select all
int myVar;
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Code: Select all
class Class
{
public:
Class(): m_data(0) {}
inline int size() const { return m_size; }
inline void SetSize(int size) { m_size = size; }
private:
int m_size;
};
Code: Select all
void MyThing();
Code: Select all
int MyThing();
Code: Select all
int iNumber = 0;
Code: Select all
std::string sString;
Well if you wanna talk about useless, you might wanna look at how inline works.. those functions (size() and SetSize(int)) are implicitly inline already so saying they are inline is just redundant.. Its like doing "register int a" instead of "int a", the compiler will put it in the register regardless of what you ask it to do, "nowadays..."(this is not true for old compilers)adikid89 wrote:I hate Hungarian notation.. it's useless nowadays...
I like to use upper camel case, and m_ for member data and s_ for static member data... The reason is because when you type m_ or s_ you get the member data with intellisense(or similar systems) so it'll make life a tad easier. For small get/set functions is use low case though..Code: Select all
class Class { public: Class(): m_data(0) {} inline int size() const { return m_size; } inline void SetSize(int size) { m_size = size; } private: int m_size; };
Yes.. actually I did know that... but still I like to explicitly inline them.. looks cleaner(that is.. i like it better that way). And yes, I know what the hungarian notation is used for, but I don't want to right a i or something before every variable, when I can easily check that with by running the cursor over a variable/function/class/whatever. I used m_ and s_ for intellisense...avansc wrote: Well if you wanna talk about useless, you might wanna look at how inline works.. those functions (size() and SetSize(int)) are implicitly inline already so saying they are inline is just redundant.. Its like doing "register int a" instead of "int a", the compiler will put it in the register regardless of what you ask it to do, "nowadays..."(this is not true for old compilers)
secondly, even if they were not, the compiler is smart enough "nowadays..." to know when to make a function inline, and that putting the keyword inline does not mean it will be inline(its a request, not a mandate). Also, if you inline a lot, your code gets big, and you can run into thrashing issues. If you force your inlines, you WILL run into thrashing issues.
And lastly, dont you think that your naming convention is a form of hungarian notation, you place those preceding characters to tell you something about the object to make it self evident what they type or scope is..?