- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Because the compiler says:
U:\VSP\TextGuid\Form1.cs(77): Cannot convert null to 'System.Guid' because it is a value type
That's why they created Guid.Empty.
And that's also why you should never compare guids with == like mentioned by the original poster somewehere on the previous page. Thats what .Equals is for.
Drak
Admin
This is also common in php (at least for the not object-oriented extensions).
Admin
System.Guid is a value type, and as such it cannot be null. Guid.Empty is provided as a static field for the same reasons that String.Empty is provided.
With C# 2.0 you will be able to specify a Guid as being nullable; for example:
People who don't use Pascal Casing for methods in .NET languages (C#/VB.NET) should be shot, as that is what the defined naming conventions call for:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconnamingguidelines.asp
See the section on Capitalization Styles for further information.
Admin
May I shamelessly advertise my website to generate GUIDs online? www.guidgen.com. [:$]
Admin
Yeah, all ten of those networkless win32 programmers left. You might be interested to know that this behavior ended with NT4 (which always had the same last 6 bytes, card or not; they were the MAC address). It's been widely documented (even on this site!) so you might want to do a bit of research before you spout off the ol' legends. Here's an article on the topic, and even info on pros and cons of GUIDs (requires registration):
http://www.informit.com/articles/article.asp?p=25862&seqNum=7&rl=1
The real wtf is this code a few lines down where he stores and retrieves the GUIDs by saving them in the registry, registering them as shell extensions for text files. $5 says they're there, and anyone who wants to know why explorer crashes when they click on a text file is told it must be a virus.
Admin
The company I work is developing a huge white elephant which is supposed to be the be-all-and-end-all of healthcare applications (of course in the Indian development arm, and slowly rendering us 'legacy' developers obsolete as more of the functions get absorbed).
The database uses GUIDs as the primary keys (and by extension, the foreign keys) for every table. Of course, being for SQL server, you'd think they would use the GUID datatype? Nope, they use a 36 character length field, and store the literal string (e.g. 'F2A94419-12AD-4244-87F2-F1D7D21997F6'). That is a major WTF.
Of course, our legacy applications which we are still developing and maintain run about 20 times faster with more functionality, but hey, this is progress isn't it ? You get what you paid for, a .NET monstrosity which requires four servers to run.
Admin
How about l33tcase?
r00z!
dZ.
Admin
Of course it's a HW issue! Just take away the extra 3 processors and see the application working fine!
Admin
The point is simply that he's wrapping integer IDs in GUIDs . GUIDs are unique, random, and non-sequential. However, this might be just some kind of hack to make 2 systems compatible, and IMHO is not a really big WTF. If you had two systems talking with each other, one using ints, and one using GUIDs, and you could not chance that, this would be a solution. Another solution would be to make an additional mapping table, but that would only make it even more complex.
IMHO it's ugly, but not a WTF.
Admin
It's reasons like this that we need to have some sort of master/apprentece program for developing software. I'd bet a paycheck that this system falls apart in a year ... I'd even bet another paycheck that this system will be responsible for the deaths of quite a few people due to messed up perscriptions, appointments, or whatever.
Admin
C# strings are reference types, and therefore can be null. string.Empty is simply "". string.Empty != null.
Admin
wo-oo-wo-oo-wo-o-oo
guids!
good god!
what are they good for!
Admin
I know, but Ruby also follows the convention of naming methods that change the receiving object with a ! suffix.
Admin
Haha, let's start yet ANOTHER off-topic thread! Let's bash this moron for not even knowing English! Raise your hand if you're an Object Orientated programmer.
Hmm, only one hand went up. Is that all?
Admin
Holy sh** Batman. Are we gonna protest for a a math lib for Guid in CLR 3.0?
public bool checkDivBySeven(Guid a)
{
return (a%7==0);
}
Admin
Exactly... which is why I find myself typing things like
if (s != null && s != "") {
// do something w/ s
}
Admin
I do the same thing, but I think once I read here that the really l33t people use
if(s!=null && s.length > 0){
//do something w /s
}
can someone confirm?
Admin
WTF difference???
From Guid code:
Admin
Admin
jeez....haven't you been following the PascalCase subthread?
that should be CheckDivBySeven.
Admin
I was talking about the great CamelCase debate, like everyone else in this thread. Move along, nothing to see here. :^)
Admin
'Orientated' is a perfectly acceptable word that is equivalent to 'oriented'. It's use is more common in Britain (where English originated.)
So, yeah, You don't usually hear the term Object-Orientated progamming but it definitely correct English.
Admin
(s.Length > 0) works ~5 times faster than (s == "") or (s == String.Empty)
Admin
The correct link is:
Http://Msdn.Microsoft.Com/Library/Default.asp?Url=/Library/En-Us/Cpgenref/Html/CPConCapitalizationStyles.asp
Admin
What if you have two NICs?
Admin
And I'll bet a paycheck that it uses a flash interface.
Admin
"Orientated" is in common use as an folk derivative of "orientation" (which has displaced "orient" as a noun meaning roughly the same thing as "attitude", where "orient" has remained the verb meaning "to adjust [ones] attitude in space"); it is not correct in this sense. It may become so through continued use. "Flammable" made the jump, and "irregardless" has lost the colloq tag in many dictionaries.
There is one generally accepted meaning for the verb "orientate", and that is to turn or face to the east (as for prayer). And that's where your assertion falls down -- those OO programmers who don't turn west to Redmond face the Sun [:)]
Admin
I make no claims as to the authority of this source, but this is my understanding of the controversy:
http://www.worldwidewords.org/qa/qa-ori1.htm
My understanding is that many British people don't use 'oriented' at all and they think it's incorrect.
In the Merriam-Webster dictionary, the defintion for the transitive sense of orientate is literally a link to the word 'orient'.
Maybe I'm missing your point here but I think there are a lot of people that disagree with you on this.
Admin
You are missing the point. Re-read the last sentence.
That being said, dictionaries are descriptive, not prescriptive, unlike style guides. They merely indicate how words are being used, not whether or not the usage is correct. I used to love the microprinted Oxford because I could prove that I never misspelled anything. (That is true in most cases, at least. The big Oxford will lend its opinion on usage from time to time; the editors don't always catch the comments in the citations.)
Admin
No, I didn't miss that. I disagree with it.
Admin
Autoinc numbers as DB keys have their own issues. While GUIDs are big and bulky and may cause DB indexing and fetching to take longer than really necessary, you are guaranteed that your keys are 'non-continguous' which gives you all sorts of nice flexibility that the 'continuous keyspaces' that autoincs produce don't have.
Admin
Flexibility in order to do what?
Admin
ORDER BY NewID()
for example. Non-contiguous GUID's allow for this very good pseudorandom ordering of arbitrary SELECTs. (ORDER BY RAND() doesn't work because RAND() takes the same value for all rows)
Admin
OK, I can count the number of times I've needed to do that on zero fingers. If I needed to do that I probably wouldn't do it in the DB either. It definitely doesn't seem worth the effort or cost. Any other things this helps with?
Admin
You don't need it - but I do. I've had requests to send out two subtly different marketing pieces to randomly selected slices of our current customers. The easiest way for me to do that was to do SELECT TOP 50 PERCENT * FROM Customers ORDER BY NEWID()
Leaving the default order would have defaulted to the primary key - in my case, an identity field - which would send one of the marketing pieces to all customers older than the median age, and one to all the customers newer than the median age.
Admin
OK but there are other solutions that don't queer-up the data model. My point was if this is the only thing that this is good for, I remain unconvinced that it's a good idea. The other thing about that solution that comes to mind is that you are guaranteed to get the same 'random' sample each time you do the query which may or may not be a good thing.
Admin
Just curious here. What are you going to do when you overflow the 32 bit integer variable with the data from 128 bit integer during this conversion?
Admin
pharmacie en ligne avec ordonnance https://kamagraenligne.shop/# pharmacie en ligne avec ordonnance