for example, we have two classes for parsing the resumes, one to parse Excel and the other to parse HTML.what my colleagues love to do is to name these two classes the same name and put them into different namespace,like shown as below:
namespace XX.ResumeParsers.Excel
class ResumeParser{}
namespace XX.ResumeParsers.Html
class ResumeParser{}
I feel it is not a good idea, I'll prefer to rename the classes, and put them into one namespace(but in different files if needed):
//in Excel folder under ResumeParsers folder
namespace XX.ResumeParsers
class ExcelResumeParser{}
//in Html folder under ResumeParsers folder
namespace XX.ResumeParsers
class HtmlResumeParser{}
thus, the Hierarchy still exists in the folder, but the namespace is the same(do not match the folder hierarchy exactly), is that OK?
and if I am right, any idea how to persuade my colleagues? or is there any significant drawback in their solution?
thanks.
It's not usually a good idea, no - particularly if you need to use both classes from the same code. Whether they should be in different namespaces or not is a separate decision, but I'd definitely call them
HtmlResumeParser
andExcelResumeParser
instead of trying to make the namespace communicate context. It will make it much easier to determine exactly what you're talking about when reading code.