views:

326

answers:

9

I am developing a framework, and some of the objects have reaaally long names. I don't really like this, but I don't like acronyms either. I am trying to come up with a shorter name for "EventModelSocket", basically a wrapper around the .Net socket class that implements various events, and methods to send files, objects, etc. Some of the objects have really long names due to this, such as "EventModelSocketObjectReceivedEventArgs" for example.

I've tried everything from a thesaurus, to a dictionary to sitting here for hours thinking.

When you come upon situations like this, what is the best way to name something?

+10  A: 

Well, are the long names hurting something?

(edit) two other thoughts:

  • use var in C# 3.0 - that'll save half the width
  • if you are using the type multiple times in a file, consider a type alias if it is annoying you:

    using Fred = Namespace.VeryLongNameThatIsBeingAnnoying;

Marc Gravell
With a lot of source files in the SolutionExplorer, its more productive to be able to quickly glance and find what you need without having to resize it, and read through a list of really long names. There's quite a few source files related to this single object, an alternative name would be better
David Anderson
+1  A: 

I for one use the long name. With intellisense typing out the name isn't that important, unless you are using a 15 inch monitor.

If I had to reduce the name I might go with EvtMdlSck just make the work shorter but still understood. Even though that is not my preference.

David Basarab
+17  A: 

Push some of it into the namespace.

For example:

EventModelSocketObjectReceivedEventArgs

becomes

EventModel.Sockets.ReceivedEventArgs
John MacIntyre
Wow! that was a fast down vote! What the heck was it for?
John MacIntyre
This doesn't help if you are using EventArgs on a winform or something. Then you have to use the full name and you are in the same situation as before.
David Basarab
Great suggestion. +1
Randolpho
I like this idea a lot actually. +1
David Anderson
@Longhorn213 ReceivedEventArgs doesn't clobber with anything in the framework namespaces -- what's wrong with using a using statement? Plus, it solves the real issue David Anderson was having (see comments on another answer) which was navigating in the solution explorer.
Randolpho
I wish I could upvote this again.. it worked out really well. Thanks!
David Anderson
Namespaces aren't the right tool for this in C#, because namespaces are intended to be merely organizational tools. You'll see the problem when you need to talk to two 'ReceivedEventArgs' types in the same file. Nested types work well, though.
Jay Bazuzi
John MacIntyre
@David Anderson-Thanks, I'm glad it works for you.
John MacIntyre
http://msdn.microsoft.com/en-us/library/ms182162.aspx :)
Sciolist
The identifier of this component is still reallly long. It doesnt really address the problem - does the name of this class tell me what it does or what value it holds ?
mP
@Jay Bazuzi-I'dThis is going to be a framework that will be used for our products in the future, so it already has as a very organized structure. BitFlex.IO, BitFlex.Windows.Forms, etc. His suggestion worked out nicely because I already have BitFlex.Net.Sockets, and a 100% FxCop passed library :)
David Anderson
If I run into the need for several 'ReceivedEventArgs' objects, I'll deal with it when it comes up :P
David Anderson
Wow ... when I wrote this, I thought it was pretty mundane. I had no idea it would be controvertial. This answer has 3 down votes so far .. it's my second most down voted answer.
John MacIntyre
I honestly don't see why it should be downvoted.. It was exactly what I needed, and is in my opinion the best way to go about it for my situation. :\
David Anderson
And not to mention it is what should be done for class library/framework development, if I am correct.
David Anderson
@John MacIntyre: I agree, it doesn't deserve downvotes. That said, naming conventions are up there in the list of things programmers get religious about, so folks who are downvoting you are probably doing it out of blind prejudice. They're idiots; ignore them. :)
Randolpho
+8  A: 

I would just suggest using the most concise naming that describes the object. If EventModelSocketObjectReceivedEventArgs does that, move on. My 2 cents.

Pat
+4  A: 

Years ago when I was in a programming class, the prof quoted the statistic that a piece of code is typically read 600 times for each single time it got modified. Nowadays, I would assume that this is no longer true, particulary in TDD environments where there's lots of refactoring going on. Nevertheless, I think a given piece of code is still read many more times than it gets written. Therefore, I think the maxim that we should write for readability is still valid. The full form of a word in a name is more readable, since the brain doesn't have to do the conversion. Comprehension is faster and more accurate.

The tools we have today make this so easy with autocompletion and the like. Because of this, I use full words in variable names now, and I think it's a good way to go.

Don Branson
+2  A: 

If you need to go through that much effort to find an alternative name, you already have the correct name. Object/method/property names should be self documenting. If they do not describe their exact purpose they are misnamed. There is nothing wrong with long names if they give the most clear understanding of the purpose of that object.

In this age of intellisense and large monitors there really is no excuse to not be as descriptive as possible in naming.

Jim Petkus
A: 

Some criticisms on your naming...

Why DOES your component have the word "model" in its name - isnt that a bit redundant.

Since your component seems to be a messaging hub of some sort why not include Message in its name. What about MessageSender.

To solve your problem I would create an interface and given it a generic name like MessageSender and an implementation which is where you include the technology within the name like RandomFailingSocketMessageSender.

If one wishes to get a good example of this take a look at the Java or .Net libraries..

from Java. interface - class/implementations... Map - HashMap, LinkedHashMap. List - LinkedList

Details regarding the technology or framework used eg words like "Socket" or perhaps to use a contrived example "MQSeries" shouldnt be part of the interface name at all.

MessageSender seems to IMHO sum up the purpose of your component. It seems strange that your thing which sends "files" and "events" doesnt include the those two descriptive words. The stuff your using in your naming is superfluous and IMHO doesnt match your description of the component.

mP
This is just a socket wrapper that gets rid of the need to write the code to send and receive files, large data, objects, etc and without the need to writeup events to show progress of the send/receive operations. It implements its own "HTTP like" protocol, but is essentially just a custom socket :)
David Anderson
I also generally dislike the word "model" in a classname, but if the sockets are dedicated to passing Event Models then it's the right name.
DJClayworth
Interface names should be short and simple without mentioning technology I'd possible. It's a common pattern found in java or dot net.
mP
+2  A: 

Don't remove the vowels or something crazy like that.

I'm with the "stick with the long name" people.

One thought is that if the names are that awkward, maybe some deeper rethinking of the system is needed.

Ask Bjørn Hansen
A: 

In general I believe in classnames that accurately describe their function, and that's it's OK to have long names. If you think the names are really getting long, what I would suggest is finding a concept that is well-known to your programming team and abbreviating that. So if "Event Model Sockets" are a concept that everybody knows about, then abbreviate them to EMS. If you've got a package that is entirely about Event Model Sockets then abbreviate them to EMS in all the classes internal to that package. They key here is to make sure the name is in full for anyone who might not be familiar with the concept and abbreviated for anyone who is.

DJClayworth