views:

153

answers:

8

I want to inherit the DevExpress ComboBoxEdit control, and am wondering if naming my class the same as the DevExpress class is bad practice.

Here's the derived class declaration:

using System;
using System.Collections.Generic;
using System.Text;

namespace MyApplication.Components
{
    public class ComboBoxEdit : DevExpress.XtraEditors.ComboBoxEdit
    {
    }
}

Should I rename MyApplication.Components.ComboBoxEdit to something else like MyComboBoxEdit?

A: 

Well, it's legal to do it, but I would advise against it because it would only cause confusion... Why not name it "MyComboBoxEdit" or "SuperComboBoxEdit" or anything you like ?

Thomas Levesque
+10  A: 

There's must be a reason why you're creating your own ComboBoxEdit. I would use that reason in the name of the class.

Vadim
The reason is that I'm overloading the EditValue property to avoid cross-thread exceptions. I guess I could call it ThreadSafeComboBoxEdit, but it's just so verbose...
Joe
Less verbose than MyApplication.Components.ComboBoxEdit, though! (By a hair.)
Jeff Sternal
I believe there's nothing wrong with a long class name.
Vadim
Should I modify the question to ask if a name like ThreadSafeComboBoxEdit is a good name, or start a new question???
Joe
I believe it's a question for people you work with. I personally likeThreadSafeComboBoxEdit name.
Vadim
Ok, thanks Vadim :)
Joe
+2  A: 

It's a good idea only if you want the maintenance dude to hate you with an intensity of a thousand suns.

AngryHacker
A: 

Technically, your class has a different name already. Your class is named "MyApplication.Components.ComboBoxEdit" and the DevExpress class is named "DevExpress.XtraEditors.ComboBoxEdit".

That said, your class likely has different behavior to the DevExpress class. For this reason you should probably give your new class a more descriptive name.

Robert Venables
A: 

If it's not confusing for you (and your coworkers / other people that will work on the application) then it's perfectly legitimate to use the same name - that's why namespaces exist, after all.
Otherwise you might want to name your class after the reason you're extending the base one, e.g. ComboBoxEditThatAlsoDoesThisAndThat, rather than using the generic My prefix...

Paolo Tedesco
+1  A: 

Use common sense.

1) If both your and the DevExpress combo boxes are used throughout the application name it something different (but still something that reveals its identity).

2) If you have a well defined convention that you will inherit all components from a certain namespace and use only your own then I see no problem with doing this.

George Mauer
Right now I can't guarantee that only my class will be used, but I see your point.
Joe
A: 

I too would advise against a naming collision. With respect to the name, if you have a reason to create an inherited control, then you should be able to give a useful name.

The My prefix is severely limiting and has little value to newcomers reading the code. You also risk running into MyComboBox2 when you need a new one.

Austin Salonen
A: 

There is nothing illegal about it, but if you end up with a using statement like this in a different file, you'll run into problems.

using DevExpress.XtraEditors;

Then you end up burying the class name in intellisense (since two classes have the same name); so then you'll have to explicitly specify which class you are using.

I'm assuming... I've never used Dev Express. I don't know if XtraEditors is a namespace.

Hawker
XtraEditors is a namespace.
Joe