Why sort class members alphabetically?!

I personally do NOT like sorting class members alphabetically. Once in a while I run into developers who prefer it sorted alphabetically, usually on the grounds of believing it’s easier to find things around that way. I disagree. Let me explain why…

Take the following class as an example:

Now here’s the same class with the members sorted alphabetically:

To me, the code in the first example is much easier to understand. Related properties are grouped together, and they’re listed in an order that makes sense.

If I do want to find something alphabetically, I can use the dropdown menu that lists all members that way:

Or, better yet, I can hit Alt+\, which is the Resharper shortcut to “Go to File Member…”:

Advertisements

  1. Leave a comment

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: