views:

562

answers:

11

Some friends and colleagues of mine have a little running contest to find or write the longest class/variable/property/method names possible. Keep in mind, we try to be good boys and girls and keep the naming intelligible and concise, while still explaining what the thing does via its name.

Sometimes it just doesn't happen though. Have you run in to this? I'd just like to see what's out there. (Maybe my friends and I aren't as crazy as we think)

Note: I'm not looking for bad naming. That's already here. I'm looking for good naming that just got a little long.

+1  A: 

Check out Apple's documentation. They're kings at that. Very descriptive, but sometimes miles long. A couple of examples from the NSString class:

NSString.completePathInfoString:caseSensitive:matchesToArray:filterType NSString.stringByAddingPercentEscapesUsingEncoding

My favourite in the Microsoft world: SetProcessWorkingSetSize

DannySmurf
+5  A: 

I find it's nice to have long test names which describe the test. For instance:

testMapWithOneEntryAllowsDifferentEntryPreservingFirst
testMapWithOneEntryAllowsDuplicateEntryOverwritingFirst

(These are just examples off the top of my head... you get the idea though.)

Jon Skeet
+1  A: 

In the apple mail app:

_synchronouslyTellServicesToRegisterAndSync()

In a app I wrote:

User.CanViewRestrictedItems()

I an app a colleague wrote:

Profile.DisplayMyDraftOrPendingProfile()
Profile.DisplayMyApprovedProfile()

Just to get started.

Zachary Yates
+2  A: 
protected virtual OcrBarcodeSymbologies GetSupportedBarcodeSymbologies() { }
plinth
+2  A: 

The excellent GTK+ library "suffers" from this. It has very neatly named functions, but since the main API is C, and GTK+ is very object-oriented, it must encode class names in the functions name. The constructor for class X is X_new(), and so on. This leads to beaties such as gtk_recent_chooser_widget_new_for_manager().

I'm sure there are even longer function names in there, this was just one that I found quickly. :)

unwind
+6  A: 

It isn't really long but my favorite variable name ever was to indicate that a user had opted in to receive email.

User.IsSpammable

denny
If you are not too obsessed with booleans starting with "is", you could do User.canSpam
Bemmu
+2  A: 

Some times ago, I had a problem with Hibernate. I got a NullPointerException in the method called findIntendedAliasedFromElementBasedOnCrazyJPARequirements !

romaintaz
+2  A: 

Long variable names don't bother me as long as there's not an obvious more concise name and the naming is sane. For instance, in Kamaelia, there's a class type named this:

threadedadaptivecommscomponent
Jason Baker
+1  A: 

A naming convention I've seen, years before fluent became en vogue

public DataSet SelectAllUsersWhereDobIsGreaterThan1980AndIsMaleOrderByNameAndAge()
Chris S
A: 

org.aspectj.weaver.patterns;
public class HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor {
boolean ohYesItHas = false;
public boolean wellHasItThen/?/() { return ohYesItHas; }
... more methods...

Albert
He said he wasn't looking for bad code.
John
+2  A: 

This isn't a class name but an enum, but it's a lot longer:

VirtualMachineDeviceRuntimeInfoVirtualEthernetCardRuntimeStateVmDirectPathGen2InactiveReasonOther

from the VMware vSphere API. Google for it and you'll find the online documentation.

wsd
Definitely the new winner.
Zachary Yates