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


This one scream of IEnterpriseAuthenticationProviderFactoryManagementFactory style patternitis :

41 DynamicUrlManagerDataRepositoryFactory.cs

(A handy web site exists if you fancy more names like this.)


Whilst this next one looks like a bad case of nhibernatisis:

37 NHibernateSessionFactoryRepository.cs


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



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


And finally several cases where people just could not be bothered to either name or delete the file:


If you have a large code base why not run the command above? Let me know if you find anything interesting!


  1. Tim · March 9, 2011

    Very entertaining post Jason 🙂 I can’t help but feel partly responsible for some of those BDD names!

    • jasonneylon · March 10, 2011

      Glad you liked it! Now I have been doing ruby for a bit the long names look even more excessive. there is definitely a drive towards conciseness in ruby and functional languages + I’m not so convinced by SRP anymore – especially when you have loads of classes with one single one line methods. Its too early for me to articulate just yet though.

  2. Mary · January 22, 2013

    Here’s a slightly golfed version with less pipes and pids:

    $ find . -name “*.cs” | awk -F”/” ‘{ print length($NF),$NF} | “sort -n”}’

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s