What should be done exactly when the most obvious class name for a component is taken by a framework? In my case, I need to make a class that describes an HTTP request. Of course, the most common name is "taken" as System.Web.HttpRequest. What should I do? This project will be used in a web context, so I'd really rather not force people to not import the System.Web namespace, or type out all of my class names manually.

What is the usual way of dealing with this? I can come up with this:

  • Prefix class name with a project shortname
  • Try to come up with a different name that means the same thing(I've tried and can't come up with anything)
  • Force users to choose between namespaces
  • Is it really a generic HTTP request, or is it a request in a specific module? E.g. is it always a request to some API? – Joachim Sauer Oct 22 '12 at 8:14
  • @JoachimSauer It's sort of a generic HTTP request. I'd like to use the builtin HttpRequest class but Microsoft decided to make it a sealed class and therefore useless for my case – Earlz Oct 22 '12 at 13:29
  • In what way is it better than the built-in HttpRequest? Maybe you could use that, something like SecureHttpRequest. – svick Oct 22 '12 at 20:11

You can use the using alias directive to avoid having to disambiguate everywhere, e.g.

using HttpRequest = MyCompany.MyProject.HttpRequest;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.