Crazy Long C# Class Names
One of my colleagues, Michael Patricios, emailed a link to a funny Daily WTF article around the office yesterday. It made a passing reference to very very long class and interface names such as IEnterpriseAuthenticationProviderFactoryManagementFactory. This struck up both my curiosity and my desire to maser the Unix shell so I spent 5 minutes knocking up this set of commands:
admin ~ $ find . -name "*.cs" | xargs basename | awk '{ print length($0),$0 | "sort -n"}'
What does it do? It find all C# files underneath the current directory, sorts them by ascending filename length and finally prints out the filename and its length. I was expecting all sorts of insane filenames, but in fact the uSwitch code base was relatively sane.
The results
NB: If you wrote any of these classes don’t be offended – this is only a bit of fun. I have been guilty of plenty of odd naming too!
Comment as class name
This longest non test class name was mine. I am a bit disappointed that I never went back to delete it though:
65 TemporaryClassSoThatExistingCmsContentWontBreakBetweenReleases.cs
Patternitis
This one scream of IEnterpriseAuthenticationProviderFactoryManagementFactory style patternitis :
41 DynamicUrlManagerDataRepositoryFactory.cs
(A handy web site exists if you fancy more names like this.)
Nhibernatisis
Whilst this next one looks like a bad case of nhibernatisis:
37 NHibernateSessionFactoryRepository.cs
BehaviourDrivenDevelopmentGivesYouReallyLongTestNames
The longest filename were from our BDD test-obsessed phase a year or two ago:
57 specs_for_CustomerSatisfactionOverallSummaryController.cs 59 specs_for_LastLinkHasLastChildCssClassSiteMapTransformer.cs 62 specs_for_SendResultsEmailImmediatelyToMyFriendEventHandler.cs 72 specs_for_CurrentNodeHasCurrentCategoryCssClassSiteMapLinkTransformer.cs
gulp!
Zen.cs
At the other end of the spectrum, were some short and intriguing zen-like class names:
8 Party.cs 8 Smurf.cs 8 Water.cs 8 motor.cs 8 Logic.cs 8 Fresh.cs
Meh.cs
And finally several cases where people just could not be bothered to either name or delete the file:
Class1.cs
If you have a large code base why not run the command above? Let me know if you find anything interesting!