|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using using verses specifying the namespace completely.What's the general feeling on using the using keyword versus spelling the
type out completely. For instance, do most people put a using in so they can just say MyNewType or do people not use a using and they specify the namespace/type like MyNameSpace.MyNewType Just curious. I'm leaning towards not using the using and specifying things because then I know for a fact it's my datatype not a system datatype. TIA - Jeff. Whatever your decision, keep it the same in all of your code. It will
make it easier for other people to read it if you keep everything the same. I guess it's a matter of personal preference. I personally put a using statement in so that i dont have to continually type out the namespace, unless of course I have two classes that are named the same, then I type out the full namespace. Like I said, just keep it uniform, it will make everything alot easier, this also applies to private member variables, property accessors, class names etc. as far as naming conventions go. There is an article on MSDN (link below) that deals with the naming guidlines (camel notation, hungarian etc) and other guidelines that you should use. heres the link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconnamingguidelines.asp UJ <f***@nowhere.com> wrote:
> What's the general feeling on using the using keyword versus spelling the You'll find that your code is much more long-winded. Of course, you can > type out completely. > > For instance, do most people put a using in so they can just say > MyNewType or do people not use a using and they specify the > namespace/type like MyNameSpace.MyNewType > > Just curious. I'm leaning towards not using the using and specifying things > because then I know for a fact it's my datatype not a system datatype. hover over a variable to find out its full type (IIRC) if you really need to - but most of the time you shouldn't need to. If you avoid giving your types the same name as common system ones, it shouldn't be a problem. I've worked with code which (to me) didn't have enough "using" statements. It gets very annoying very quickly. Consider: System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex (".*"); compared with: Regex regex = new Regex(".*"); Which of them makes the most important bits of the code (which for me are the type name, the fact that you're calling a constructor, and the pattern) the clearest? How important is the namespace in that, really? -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too
Other interesting topics
c# CP210x Wrapper InteropServices IntPtr HandleRef problem
Increase all digits in a number(string) one step Anonymous Methods As ThreadStarts Sockets, to be continued... C# Books Refering to Object Members in A Collection in an ASP.NET BoundColu finding the current user name accessing an ASP.NET page Embedding an image in a dll Form Minimize Using a Class Library Settings File in ASP.NET 2.0 |
|||||||||||||||||||||||