473,503 Members | 3,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using using verses specifying the namespace completely.

UJ
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.
Mar 10 '06 #1
2 1354
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/de...guidelines.asp

Mar 10 '06 #2
UJ <fr**@nowhere.com> wrote:
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.


You'll find that your code is much more long-winded. Of course, you can
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
Mar 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1315
by: Neil Zanella | last post by:
Hello, I have seen code that does the following: enum Letter { X, Y, Z, numLetters }; Is this considered good or bad code? On one hand, the code seems more maintainable because no matter...
13
2210
by: Robert Lario | last post by:
C# verses VB.Net Which Way to go. I am sure this issues has come up before. Please direct me to any good articles that cover this issue. Ideally some neutral assessment. Thanks
3
5502
by: Tom Jones | last post by:
I do not understand what is meant when someone states that a given method is "hidden" verses overriden. Would someone please provide a short example of both cases and why you might want to...
5
1592
by: Davíð Þórisson | last post by:
I've never understood fully, why do I have to td eg: using system; using system.data; I would have thought that the top line imports system and all of its submembers, including data??
7
3438
by: archana | last post by:
Hi all, Can someone tell me meaning of this stmt:- 'A structure must have at least one nonshared variable or event member; a class can be completely empty'. Because if i have code like...
30
4063
by: Pep | last post by:
Is it best to include the code "using namespace std;" in the source or should each keyword in the std namespace be qualified by the namespace tag, such as std::cout << "using std namespace" <<...
10
2633
by: cykill | last post by:
Hi. I'm new to asp.net and I've been searching on the net and in book on how to use custom namespace. I've created my own custom namespace and I just need a straight answer on where to put the...
3
3365
by: ak | last post by:
Q1: I am looking to find/build a table of PHP version verses timezonedb version shipped with it. For example, I think that 5.2.0 updated the timezonedb to the 2006.14 version. Is there a table of...
11
3469
by: Ed Bitzer | last post by:
I have been able using the namespace System.Web.Mail and its method Smtp.mail.send to mail simple text messages to a small group within our 55 and older community. I need help expanding the...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7258
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3156
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.