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?
There's must be a reason why you're creating your own ComboBoxEdit. I would use that reason in the name of the class.
It's a good idea only if you want the maintenance dude to hate you with an intensity of a thousand suns.
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...
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.
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.
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.
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.