You are not logged in.

#1 2010-08-05 04:02:31

crabmarkjellozest
Member
Registered: 2010-07-09
Posts: 20

What's with the trend of capitalizing function names?

Did I miss the boat?  This seems counterintuitive to me.  Maybe it's a Windows-centric thing?

http://google-styleguide.googlecode.com … tion_Names
http://msdn.microsoft.com/en-us/library … 71%29.aspx

Offline

#2 2010-08-05 04:22:33

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: What's with the trend of capitalizing function names?

It's strange. When I write in C, I keep all functions lowercase. However, when I write in Python, I keep it capitalized, such as OpenWindow(), CloseWindow(), etc.

Offline

#3 2010-08-05 04:28:14

Square
Member
Registered: 2008-06-11
Posts: 435

Re: What's with the trend of capitalizing function names?

I tend to just go with whatever looks better in a given situation.

But, then again, I use 2 spaces for indenting in python. *hides*


 

Offline

#4 2010-08-05 09:15:49

otterfox
Member
Registered: 2010-08-05
Posts: 21

Re: What's with the trend of capitalizing function names?

It's a matter of personal taste.
First and for most I will keep the same style as whatever project I'm working on.
If it's my own project I usually google up what the common idiom is for each language.


<insert hardware wankery>

Offline

#5 2010-08-05 09:47:28

Zeist
Arch Linux f@h Team Member
Registered: 2008-07-04
Posts: 532

Re: What's with the trend of capitalizing function names?

Like otterfox I tend to stay with whatever style was used on the project before if I join an existing project.

Personally I like to start function names with a lower case letter.


I haven't lost my mind; I have a tape back-up somewhere.
Twitter

Offline

#6 2010-08-05 10:01:51

hume's doona
Member
Registered: 2009-12-11
Posts: 206

Re: What's with the trend of capitalizing function names?

for me:

function = lowercase
Object = uppercase

Offline

#7 2010-08-05 11:16:24

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: What's with the trend of capitalizing function names?

My C projects tend to use all lowercase. I have some weird stigma about seeing uppercase (usually camelCase) in C.

Tangent: Go uses capitalization to determine visibility. This is true of both functions and variables.

foo = private
pkg.Foobaz() = public

Offline

#8 2010-08-05 11:49:36

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: What's with the trend of capitalizing function names?

crabmarkjellozest wrote:

Did I miss the boat? This seems counterintuitive to me. Maybe it's a Windows-centric thing?

From the small amount of time I've spent studying and using the Windows API, yes, the Windows API has functions that are spelled with camel-case with the first letter capitalized. That's the only place I've seen that in C++.

I'm a little surprised to see it on the Google page that you posted, but maybe not too surprised. It says functions and Classes AreLikeThis() and methods are_like_this(). Seeing how both functions and classes are used "at a higher level" than method names, I could understand why it would be done that way. Now that I think about it, I don't think I've personally decided yet which I would pick if I wrote a function along with some object oriented code.

And yes. it seems counterintuitive to me too. hmm

Offline

#9 2010-08-05 12:08:15

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: What's with the trend of capitalizing function names?

There's nothing inherently intuitive about having the first letter be lower-case - it's just what you're used to. It's no surprise C/C++ programmers are more used to lower-case; their standard libraries don't use capitals at all, but rather completely lower-case with underscores (std::for_each, std::multiset::lower_bound, etc...) - other languages will have different styles in their standard libraries.  Heck, at work, we use C++, and I've seen method names that run the gamut (GetSize, setSize, calculate_volume, etc...)

I frankly don't see the big deal - everybody's got a programming style, and those styles will differ. There's no boat to miss, really.  If you've been lower-casing your method names, then all the power to you.  Just try to keep it consistent. wink

Offline

#10 2010-08-05 12:18:01

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: What's with the trend of capitalizing function names?

It is slightly more intuitive to a German programmer as in Germany nouns have their first letter upper case anyway. So if you think of class/function names as nouns this comes more natural.

So this naming convention was inspired by a German rule? At least it is somewhat natural to me.  smile

But nevertheless, I'll always stick to the convention a given project uses.

Last edited by bernarcher (2010-08-05 12:18:46)


To know or not to know ...
... the questions remain forever.

Offline

#11 2010-08-05 12:18:22

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: What's with the trend of capitalizing function names?

itsbrad212 wrote:

It's strange. When I write in C, I keep all functions lowercase. However, when I write in Python, I keep it capitalized, such as OpenWindow(), CloseWindow(), etc.

PEP8 suggests function names should be lower_case_like_this where class names should be UppercaseLikeThis.

Last edited by rson451 (2010-08-05 12:51:32)


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#12 2010-08-05 12:22:57

Google
Member
From: Mountain View, California
Registered: 2010-05-31
Posts: 484
Website

Re: What's with the trend of capitalizing function names?

For me, constants are all caps,

#define MAXSIZE 80

Functions, structs, classes, first letter is lower case, from second word on is upper,

char getNextLetter(void);

Variables and other stuff, lower case...

That's how I like it, I am sure some people would hate it.

Offline

#13 2010-08-10 00:55:27

spupy
Member
Registered: 2009-08-12
Posts: 218

Re: What's with the trend of capitalizing function names?

I started with Java, so of course methods (or functions, whatever they are called in java) areLikeThis(), classes StartWithACapital.
I do prefer the python style for methods - like_this_with_underscores. My preference comes also from the fact that I find typing "_" easier than pressing shift for capital letters (I don't like pressing shifts with my pinkie). (It's a german keyboard, dunno how the english ones are.)
Then I did some C# and raged at the StartMethodsWithCapitals().


There are two types of people in this world - those who can count to 10 by using their fingers, and those who can count to 1023.

Offline

#14 2010-08-10 02:15:58

splittercode
Member
From: WI, USA
Registered: 2010-03-16
Posts: 203

Re: What's with the trend of capitalizing function names?

semi-interesting tidbit:  In Haskell, functions aren't even allowed to begin with a capital letter.

..and yeah, I know probably no one cares.  tongue

Offline

#15 2010-08-11 14:25:07

RetroX
Member
Registered: 2009-10-17
Posts: 106

Re: What's with the trend of capitalizing function names?

In my opinion, everything should be lowercase, and words should be separated by underscores.  Anything else bugs me.

I don't see why you need to sort things by case.  It's not like seeing String x lets me know that String is a class any more than string x.

Offline

#16 2010-08-11 14:39:50

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: What's with the trend of capitalizing function names?

RetroX wrote:

I don't see why you need to sort things by case.  It's not like seeing String x lets me know that String is a class any more than string x.

That's a good point. And in C and C++, classes and structs are in a different namespace than variables, so "string string" wouldn't even be a problem, right?

As a side not, I'm trying to get better and naming my variables after what they represent and not what they are. For example, something like "String name" instead of "String string".

Offline

#17 2010-08-11 14:45:55

RetroX
Member
Registered: 2009-10-17
Posts: 106

Re: What's with the trend of capitalizing function names?

Classes and structs in the standard libraries are all in the standard namespace, but ones that you define by yourself are not.  "string string" would work, but I wouldn't recommend using it.  Calling "string string" would really be "std::string string."

Offline

#18 2010-08-11 14:59:09

frabjous
Member
Registered: 2010-07-13
Posts: 367

Re: What's with the trend of capitalizing function names?

Isn't it a vim convention to capitalize your own custom function names to distinguish them from the built in ones?

Offline

#19 2010-08-11 15:47:06

alexandrite
Member
Registered: 2009-03-27
Posts: 326

Re: What's with the trend of capitalizing function names?

My university teaches (and enforces in the introductory CS classes) camelCasing, so I guess that's just what I'm used to seeing.  It seems easier to read than alllowercase and more compact than hyphen-delimited-function-names.

As for the code you linked, I believe the casing convention used there is for OO languages.  A private field or method is camelCased and a public field or method is PascalCased.  That way, you can tell the difference at a glance.

Personally, I like that particular convention.  Seems easy to read and holds inherent meaning for the identifiers in question.

Offline

#20 2010-08-11 17:14:36

gabriel9
Member
From: Berlin, DE
Registered: 2009-05-06
Posts: 91

Re: What's with the trend of capitalizing function names?

Don't argue about syntax, it is like fashion... smile All have their style.


"The flesh knows it suffers even when the mind has forgotten."

Offline

#21 2010-08-15 08:07:42

GraveyardPC
Member
Registered: 2008-11-29
Posts: 99

Re: What's with the trend of capitalizing function names?

gabriel9 wrote:

Don't argue about syntax, it is like fashion... smile All have their style.

Yeah, I always use camel, e.g. myFunction(), and that isn't gonna change.

Last edited by GraveyardPC (2010-08-15 08:08:07)

Offline

#22 2010-08-15 08:35:15

dcc24
Member
Registered: 2009-10-31
Posts: 732

Re: What's with the trend of capitalizing function names?

Functions: doSomething()
Constants: SOMETHING
Objects: Something
Variables: something

I use this scheme, independent of the language I use.


It is better to keep your mouth shut and be thought a fool than to open it and remove all doubt. (Mark Twain)

My AUR packages

Offline

#23 2010-08-15 18:25:15

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: What's with the trend of capitalizing function names?

splittercode wrote:

semi-interesting tidbit:  In Haskell, functions aren't even allowed to begin with a capital letter.

..and yeah, I know probably no one cares.  tongue

I only care because I use Xmonad smile

Offline

#24 2010-08-15 21:08:56

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: What's with the trend of capitalizing function names?

splittercode wrote:

semi-interesting tidbit:  In Haskell, functions aren't even allowed to begin with a capital letter.

..and yeah, I know probably no one cares.  tongue

All 45 Haskell programmers do care!

Haskell's coding convention makes sense when one is in Haskell. Needless to say, strict language constructs can either be a help or a hindrance, depending on how the coder feels about conformity.

Offline

#25 2010-08-26 19:14:25

akephalos
Member
From: Romania
Registered: 2009-04-22
Posts: 114

Re: What's with the trend of capitalizing function names?

So I can live happily because I did not miss any rule, too. The way I use in C/C++ is inspired from the conventions of certain projects, like GTK+:
- constants: SQC_COLS_ORDER
- functions/methods: sqc_gl_create()
- types/structs/classes: SqcApp
- objects/variables: *guiPtr.

I use to prefix - but in the same style - all of them except variables (unless global - eg. sqcConfig).

Offline

Board footer

Powered by FluxBB