To prefix or not to prefix: that is the question.

I’ve been mucking around with Eclipse lately (specifically, the GEF). The predominant paradigm is subclassing classes provided by the framework to provide for extended functionality.

The question is: if the class you’re extending is called ContextMenuProvider for example, do you call the subclass ContextMenuProvider or do you call it BlahContextMenuProvider where Blah is some fabricated name (such as the project name or My (shudder))?

Java provides this wonderful namespace delineator (i.e. the package) but we seem to be afraid to use it. I’m perhaps the worst class namer that there is, so if I can get out of naming a class then I’m happy! What do you think? Use a prefix or use the package defined namespace?

Advertisements

2 comments

  1. Rob,
    I prefer the BlahContextMenuProvider approach, simply because I use code completion / auto-import features frequently and already tripped over the two List classes in java multiple times.
    On the other hand, reusing the same class name would educate me to use these features more carefully.
    Yours,
    Laura

  2. I can certainly understand the “two List” problem. (Personally, I “fix” that one by not including “java.awt” in Eclipse’s “Type Filters”.) I don’t seem to have this problem with my own classes though. I think that it’s because I use “com.realityinteractive” as the start of the package name and that it *easily* distinguished from “org.eclipse” for example (just on length alone).
    I more than agree about the “use more carefully” since I have been bit more than once by not double checking the completions that I use. I think that as the IDEs provide us with more flexibility, we have to provide them with more diligence.


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