473,657 Members | 2,535 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.MyN ewType

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 1361
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.c om> 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.MyN ewType

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.Reg ularExpressions .Regex regex = new
System.Text.Reg ularExpressions .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.co m>
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
1323
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 whether letters are added or removed the value of numLetters will be correct (as long as no letter is given a number with the equal sign which makes this untrue).
13
2232
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
5508
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 "hide" a parent method's implementation verses simply overriding it (ie take advantage of polymorphism)? Thanks, TJ
5
1600
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
3443
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 class a {
30
4093
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" << std::endl; Myself I am not sure which I prefer, it is certainly easier to specify that the std namespace is being used instead of tagging each member of the namespace?
10
2647
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 namespace file so I can import them in the webpage. Can someone clarify? Thanks.
3
3372
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 PHP version verses timezonedb version. Q2: I am also looking to find a table of timezonedb version verses Olsen timezone database used to construct it. For example, I think that the 2006.16 version corresponds to the Olsen tzdata2006p.
11
3496
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 programs capabilities. Searching this forum I did not find any related information so if I have chosen poorly, I would appreciate a suggestion of a more appropriate dotnet forum. Now what I wish is the ability to send bcc's rather than to: (would be...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8726
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7320
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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 we have to send another system
2
1944
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.