• (cs)

    I love how I can recognize anything MS related or code written by MS programmers because their method and programme names always begin with upper case letters.

  • (cs) in reply to tag

    "Always," you say... Hmm, isn't consistency one of the keys to code readability? So what's wrong with them doing it that way if they're consistent about it?

  • (cs) in reply to tag

    tag:
    I love how I can recognize anything MS related or code written by MS programmers because their method and programme names always begin with upper case letters.

     

    Now you've just typed a WTF as CamelCase is the preferred coding standard of Object Orientated Languages.... Java coders will (and should) type their method names the same way.

  • Marty Thompson (unregistered) in reply to tag

    I always find UpperCamelCase to be easier to read.

    And IIRC, Java's coding standard is lowerCamelCase on method names.

  • Javier G. Lozano (unregistered)

    <FONT face=Arial>And just think, this could be just the tip of the iceberg...[:S]</FONT>

  • (cs)

    But see, this is extensible!  If you ever need more than 32 bits for orderId, just start using more bits in the GUID!

  • Diego Mijelshon (unregistered)

    I think most of you are missing the point here.
    The PascalCase for classes/members is the .NET standard, the same way camelCase is the Java standard (the parameters, though, should be in camelCase, which doesn't happen in the second method).

    The WTF is that this guy is SO Guid-oriented, he feels he need to convert everything to a Guid, even when it doesn't make any sense.

  • (cs) in reply to travisowens
    travisowens:

    tag:
    I love how I can recognize anything MS related or code written by MS programmers because their method and programme names always begin with upper case letters.

     

    Now you've just typed a WTF as CamelCase is the preferred coding standard of Object Orientated Languages.... Java coders will (and should) type their method names the same way.



    Funny, in the past 9 years working with open source software I've seen many, many ClassNames, and almost zero MethodNames in CamelCase.  And in the past 3 months working in software on the MS platform, I've seen so much CamelCase and sHungarianNotation that I feel like my head is going to spin.

    And java is extremely far from the overall scope of object oriented development, I don't do much java and I really don't give a damn what java programmers do.  (Also, I recall most of the standard java methods having lower case first letters -- albiet not classes, but methods were what I was referring to in the first place)
  • (cs) in reply to Diego Mijelshon
    Anonymous:
    I think most of you are missing the point here.
    The PascalCase for classes/members is the .NET standard, the same way camelCase is the Java standard (the parameters, though, should be in camelCase, which doesn't happen in the second method).

    The WTF is that this guy is SO Guid-oriented, he feels he need to convert everything to a Guid, even when it doesn't make any sense.


    I didn't miss the point but I found this code to be simply annoying (maybe a "why the hell?") rather than appallingly illogical so I started a seperate thread of conversation spawned in part by my having a metric-fuckton of VBScript dropped in my lap this lovely morning (god help me).
  • chep (unregistered)

    WTF: ba[0] + (ba[1] << 8) + (ba[2] << 16) + (ba[3] << 24);<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    suppose to be <o:p></o:p>

    ba[0] | (ba[1] << 8) | (ba[2] << 16) | (ba[3] << 24);<o:p></o:p>

    Parentheses are optional...

    I don't know why people (especially from VB corner) mixing OR and ADD instructions...[:^)]  

    Everything else looks fine to me - people just trying to "pack" integer into Guid therefore fool some 3rd party lib with ugly parameter or database or somebody else’s “DB layer” and make these types "compatible"… <o:p></o:p>

    Newer done this before? Well, welcome to the real world where you must have “compatibility” today (sometimes yesterday) no mater what and changing table structure/DB Layer is out of questions because it’s not your table but customer’s and he uses it in his other projects…

    I don’t see the “whole picture” from this snippet, maybe it’s really dumb solution. What I trying to say is it _could be_ a real deal. [;)]

     

  • Head Case (unregistered) in reply to travisowens
    Now you've just typed a WTF as CamelCase is the preferred coding standard of Object Orientated Languages.... Java coders will (and should) type their method names the same way.

    Umm,  no.
    Even Microsoft's own naming guideline page treats lowerCamelCase as "real" CamelCase.

    From:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcapitalizationstyles.asp

    Camel case

    The first letter of an identifier is lowercase and the first letter of each subsequent concatenated word is capitalized.

    If you read further, you will see that Microsoft recommends a mixture of (lower) CamelCase and Pascal Case (or UpperCamelCase) for .NET identifiers.  Java likewise recommends a mixture of cases depending on type -- think methods in lowerCamelCase, class names in Pascal Case.)

    Microsoft took a look at Sun's conventions, and decided to change them, even for J#, rather than go with what had been there for (at least a few) years.  Whether you think they did that in an effort to improve coding environments, to keep compatibility with their own pre-existing conventions, or just to tweak a competitor depends on the brand of tinfoil hat you wear.  But there is no "one true convention" that cuts across every language.
  • (cs)

    While silly, this is more of a WTH than a WTF.

  • (cs)

    lower_case_with_underscores_rules! (EXCEPT_FOR_CONSTANTS)

  • (cs)

    The real WTF is, of course, the unrelated argument about the capitalization of a single letter in a method name with 29 letters.

  • Perry Pederson (unregistered)

    Heh-- I'm the poster, and was surprised that people are more interested in CamelCase than using a Guid to store an int value.

    The Guid is never used for the purpose of a Guid.  The code I inherited uses these Guid<-->integer "translator" methods in several places to store an integer value (for some twisted reason) in a Guid "object".

    There are Guid comparisons in the code (if (g1 == g2)), and, to my delight even a 'empty' Guid value

          Guid gEmpty = new Guid(0,0,0,0,0,0,0,0,0,0,0);

    for those special occasions where you need to set or validate a Guid with no value.

    [:#]

  • Simon (unregistered)

    Hmmm.

    People saying this isn't a WTF. And going on about camel case.

    The WTF here is that [GU]UIDs are supposed to be unique. unique over space and time. Not a 'placeholder for some other value'.

    This may not be wrong as such, but it's - well. wrong.

    (Oh, and to th poster who claimed there was a difference in using + and |, in the code you quoted there's not. either is acceptable, but the | is more consistent as the rest of the code is bit manipulation too)

    Simon

  • Marc Rohloff (unregistered)
    Alex Papadimoulis:

    Then there are those who have to work with and maintain systems built by the wish-I-chould-change-my-name-to-a-GUID type.

    And here's your chance:

    cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&category=51340&item=7163650842&rd=1

     

  • (cs) in reply to tag

    tag:
    I love how I can recognize anything MS related or code written by MS programmers because their method and programme names always begin with upper case letters.

     

    I love how I can recognize anything idiot related or posts typed by idiots because their replies and messages always miss the point.

  • chep (unregistered) in reply to Perry Pederson
    Anonymous:

    There are Guid comparisons in the code (if (g1 == g2)), and, to my delight even a 'empty' Guid value

          Guid gEmpty = new Guid(0,0,0,0,0,0,0,0,0,0,0);

    for those special occasions where you need to set or validate a Guid with no value.

    [:#]

    May be people find "camelCase" discussion more interesting than you piece of code... [:D]<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    Ok, what's wrong with this one? <o:p></o:p>

    Forgot to use Guid.Empty? Big deal! <o:p></o:p>

    Help me people! I just couldn't see the point of today's wtf... [:S]

  • jrock (unregistered) in reply to kalahari
    kalahari:
    lower_case_with_underscores_rules! (EXCEPT_FOR_CONSTANTS)


    This is what I've always done, because I don't like CamelCaseWithAOneLetterWordInThere. this_is_much_easier_to_read.

    God invented underscores for a reason :) 

    (Then I'm a C/UNIX kind of guy, so I think you Windows/C#/Java people are kinda weird anyway.)
  • (cs) in reply to Perry Pederson
    Anonymous:

    There are Guid comparisons in the code (if (g1 == g2)), and, to my delight even a 'empty' Guid value

          Guid gEmpty = new Guid(0,0,0,0,0,0,0,0,0,0,0);

    for those special occasions where you need to set or validate a Guid with no value.


    Except that that does have a use - as a null value. You could use null, or Nothing, or whatever your language calls lack-of-an-object, but sometimes a slightly impure object model is practical. The .NET framework provides a 'null' GUID object.

  • lunk (unregistered)

    What exactly is a GUID good for? I've never run across them.

  • chep (unregistered) in reply to Simon

    Anonymous:

    (Oh, and to th poster who claimed there was a difference in using + and |, in the code you quoted there's not. either is acceptable, but the | is more consistent as the rest of the code is bit manipulation too)

    Well it's not a "consistency" issue it's "apples and oranges"...

    1 + 1 = 2;

    1 | 1 = 1; //hmm... =| must be a bug in my VS...

    BUT

    1 + 2 = 3;

    1 | 2 = 3; //Look ma! No difference!!! =)

    P.S. I have people with the same ideas at work, who debug multithreaded apps on single proc desktops and yeah! I'm getting every build: "Everything worked on my computer, donno why quatro-proc production is in ruins... Must be a HW issue..."

  • (cs) in reply to jrock

    Anonymous:
    kalahari:
    lower_case_with_underscores_rules! (EXCEPT_FOR_CONSTANTS)


    This is what I've always done, because I don't like CamelCaseWithAOneLetterWordInThere. this_is_much_easier_to_read.

    God invented underscores for a reason :) 

    (Then I'm a C/UNIX kind of guy, so I think you Windows/C#/Java people are kinda weird anyway.)

    The bad thing about camel case is when people insist that Acryonymns must remain all caps in the methods.  So instead of:  ScubaGear, you end up with SCUBAGear.  I can't seem to convince anyone that it isn't important that something is an acronym when you are naming things in code.  This was especially stupid at my last job when no one knew what the letters in the acronyms meant.  They were just words to us.

  • (cs) in reply to chep
    Anonymous:

    Anonymous:

    (Oh, and to th poster who claimed there was a difference in using + and |, in the code you quoted there's not. either is acceptable, but the | is more consistent as the rest of the code is bit manipulation too)

    Well it's not a "consistency" issue it's "apples and oranges"...

    1 + 1 = 2;

    1 | 1 = 1; //hmm... =| must be a bug in my VS...

    BUT

    1 + 2 = 3;

    1 | 2 = 3; //Look ma! No difference!!! =)

    P.S. I have people with the same ideas at work, who debug multithreaded apps on single proc desktops and yeah! I'm getting every build: "Everything worked on my computer, donno why quatro-proc production is in ruins... Must be a HW issue..."

    I think you missed the point.  The code is shifting each bit such that none of the set bits can possibly overlap.  There is no way for + to produce a different result than | when that is done.

  • joe_bruin (unregistered) in reply to chep
    Anonymous:

    WTF: ba[0] + (ba[1] << 8) + (ba[2] << 16) + (ba[3] << 24);<o:p></o:p>

    suppose to be <o:p></o:p>

    ba[0] | (ba[1] << 8) | (ba[2] << 16) | (ba[3] << 24);<o:p></o:p>

    Parentheses are optional...

    I don't know why people (especially from VB corner) mixing OR and ADD instructions...[:^)]  



    Sure, OR is the right way to do it.  But perhaps you care to tell us under what conditions these two operations produce different results.
  • chep (unregistered) in reply to dubwai
    dubwai:

    I think you missed the point.  The code is shifting each bit such that none of the set bits can possibly overlap.  There is no way for + to produce a different result than | when that is done.

    That's exactly my point! [:)]

    Just because it "works" in this particular case doesn't mean you have any excuse to use it.

     

  • Perry Pederson (unregistered) in reply to chep

    From http://en.wikipedia.org/wiki/GUID:

    Each generated GUID is "mathematically guaranteed" to be unique. This is based on the simple principle that the total number of unique keys (2128 or 3.4028 \times 10^{38}) is so large that the possibility of the same number being generated twice is virtually zero.

    All Guids are always supposed to have unique values across all space and time.  Assigning a Guid a value from another Guid could be useful if you needed to retain the unique value in an application.  But assigning an integer value to a Guid totally defeats the raison d'être of a Guid, which is that the value should always be unique.

    Creating an 'empty' Guid value implies that more cluelessness (or WTF-es-ness) is afoot; it shows that the original author intended to do more than simple Guid comparisons, but needed to assign and/or check to see if a Guid value was actually empty-- and since the sole purpose of a Guid is to provide a universally unique random value, it makes no sense to assign or test it with a "constant" Guid that has a "zero value".

  • chep (unregistered) in reply to lunk

    Anonymous:
    What exactly is a GUID good for?

    Abso-lute-ly nothin'!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    Say it again! [H]<o:p></o:p>

    --<o:p></o:p>

    Sorry, couldn't resist... [:D]<o:p></o:p>

     

  • (cs) in reply to lunk
    Anonymous:
    What exactly is a GUID good for? I've never run across them.

    Basically it is nothing more than a 128-bit number.  GUID stands for Globally Unique Identifier, and is usually created by combining things like your IP address, MAC address, and the current time.  This should come up with a completely unique number that will never be reused.  Theoretically there is a tiny chance that it will be reused, since there is nobody handing out GUIDs, there might be another one out there that is the same as yours, but the chance is so low that we pretend it is impossible.

    Their true purpose is to give globally unique IDs to COM object libraries, so you can install yours on any machine in the world and it won't conflict with any other ones.  You don't have to ask anybody for a GUID, you just create a new one and use it.  If it was only 8 bits, you could only have 256 libraries in the world before you start having conflicts.

    For something like a database primary key, you don't have to use 128 bits unless you plan to have a database bigger than the universe, so using an autoincrement 32 bit number is fine.

  • (cs) in reply to Perry Pederson

    More GUID info.

  • Matt Moriarity (unregistered) in reply to kalahari
    kalahari:
    lower_case_with_underscores_rules! (EXCEPT_FOR_CONSTANTS)

    I know a Ruby programmer when I see it!

    GO RUBY!!!

  • chep (unregistered) in reply to Perry Pederson

    [;)]

    Anonymous:

    Creating an 'empty' Guid value implies that more cluelessness (or WTF-es-ness) is afoot; it shows that the original author intended to do more than simple Guid comparisons, but needed to assign and/or check to see if a Guid value was actually empty-- and since the sole purpose of a Guid is to provide a universally unique random value, it makes no sense to assign or test it with a "constant" Guid that has a "zero value".

    There is a difference between "generating a new number" (or "creating a new instance") and working with existent ones...

    If you generating numbers without ability to at least compare them - what is the purpose of this numbers? How to use em?

    What is wrong with empty guid as a NULL-equivalent value for a value-type? How to say "undefined" in C# for Guid without using Empty?

    >> and since the sole purpose of a Guid is to provide a universally unique random value

    I think, you've mistaken Guid generator (which creates a new instance of type Guid) and Guid object - which is a container for this value therefore may contain _any_ value. The purpose of the Guid is to HOLD 16 byte value, period!

    Think of it like LAARGE int and rand() function with huuuge range... (bad comparison but fair anough) 

     

  • chep (unregistered) in reply to loneprogrammer

    loneprogrammer:
    Anonymous:
    What exactly is a GUID good for? I've never run across them.

    For something like a database primary key, you don't have to use 128 bits unless you plan to have a database bigger than the universe, so using an autoincrement 32 bit number is fine.

    The problem is in incrementing this value on the client whithout roundtrip to database (and don't give me MAX() + 1 sh*t) when you have to know PK before you insert (for child records for ex.)

    Whith Guid you (presumably) safe.

    I'm not even talking about replication... [:'(]

  • (cs)

    I have found GUIDs pretty useful when the objects are created by different people in different places (for example, a sales database where new records are added from an offline laptop and need to sync with the server).  Specially if the objects or entities are build offline, so you know the ID's will never crash. Thus making this a WTF, since these GUIDs don't have the properties associated with real GUIDs and gives you no extra security against id crashing than using a simple autonumbered int.
    --Mexican, really sorry for the broken english

  • (cs) in reply to chep
    Anonymous:
    The purpose of the Guid is to HOLD 16 byte value, period!

    Just because 16 bytes happens to be the size of a GUID instance? Um.... no.

  • (cs) in reply to spotcatbug

    Could somebody kindly explain how to create a reply with quoted text in it (without it being a garbled mess like the above)?

  • (cs) in reply to spotcatbug

    spotcatbug:
    Could somebody kindly explain how to create a reply with quoted text in it (without it being a garbled mess like the above)?

    I think you have to use IE.  You are using FireFox, right?

  • chep (unregistered) in reply to spotcatbug

    spotcatbug:
    Could somebody kindly explain how to create a reply with quoted text in it (without it being a garbled mess like the above)?

    Avoid Preview button - real WTF!  [:D]

  • (cs) in reply to WTFer

    WTFer:
    I have found GUIDs pretty useful when the objects are created by different people in different places (for example, a sales database where new records are added from an offline laptop and need to sync with the server).  Specially if the objects or entities are build offline, so you know the ID's will never crash. Thus making this a WTF, since these GUIDs don't have the properties associated with real GUIDs and gives you no extra security against id crashing than using a simple autonumbered int.
    --Mexican, really sorry for the broken english

    Broken?  Your English is better than most 'Mericans and Brits.  Written English, anyway.  Don't wanna see no more apologies from you.

  • (cs) in reply to Perry Pederson

    Anonymous:
    Each generated GUID is "mathematically guaranteed" to be unique. This is based on the simple principle that the total number of unique keys (2128 or 3.4028 \times 10^{38}) is so large

    Whatever, I totally know about numbers that are way larger than that. [:P]

  • (cs)

    Forgive me if I'm wrong, but isn't this WTF more about the particular usage of GUID that about case preferences? I may be going out on a limb here, but it seems that 98.5% of the replies have been about the choice of casing for this snippet of code. Why can't we all just get along? [;)]

  • (cs) in reply to dubwai
    dubwai:

    spotcatbug:
    Could somebody kindly explain how to create a reply with quoted text in it (without it being a garbled mess like the above)?

    I think you have to use IE.  You are using FireFox, right?


    Successfully quoted with FireFox 1.0.4.
  • (cs) in reply to Brendan Kidwell

    Brendan Kidwell:
    "Always," you say... Hmm, isn't consistency one of the keys to code readability? So what's wrong with them doing it that way if they're consistent about it?

    The idea of a GUID is that it should be universally unique. No two GUIDs in the entire universe ought to be the same. Constructing a guid like this (id, 0,0,0,0,0 ,... ) undermines the whole idea of them. You might be using a GUID object, but it is not really a GUID at all.

  • eaw4etz5rtg3wy35e (unregistered) in reply to John Smallberries
    John Smallberries:
    dubwai:

    spotcatbug:
    Could somebody kindly explain how to create a reply with quoted text in it (without it being a garbled mess like the above)?

    I think you have to use IE.  You are using FireFox, right?


    Successfully quoted with FireFox 1.0.4.


    I think it's this weird WYSIWYG thingy.
  • chep (unregistered) in reply to Foon
    Foon:

    Brendan Kidwell:
    "Always," you say... Hmm, isn't consistency one of the keys to code readability? So what's wrong with them doing it that way if they're consistent about it?

    The idea of a GUID is that it should be universally unique. No two GUIDs in the entire universe ought to be the same. Constructing a guid like this (id, 0,0,0,0,0 ,... ) undermines the whole idea of them. You might be using a GUID object, but it is not really a GUID at all.

    >>No two GUIDs in the entire universe ought to be the same.

    Are you talking about Guid-container or Guid-generator?

    <FONT color=#008000 size=2> 

    </FONT>
  • (cs) in reply to WTFer

    WTFer:
    I have found GUIDs pretty useful when the objects are created by different people in different places (for example, a sales database where new records are added from an offline laptop and need to sync with the server).  Specially if the objects or entities are build offline, so you know the ID's will never crash. Thus making this a WTF, since these GUIDs don't have the properties associated with real GUIDs and gives you no extra security against id crashing than using a simple autonumbered int.
    --Mexican, really sorry for the broken english

     

    Man, that's totally the point of GUIDs--to create "references" that are more or less guaranteed not to collide with GUIDs created on other computers.

    Note that if you are running Windows without a NIC, the last 6 bytes of any generated GUIDs using the MS tools that ship with Visual Studio will always be the same, so it's theoretically more likely to have collisions.  Of course, when you're dealing with 10**<SUPER>38</SUPER>, what's a couple of orders of magnitude among friends?

  • Davey (unregistered) in reply to FrostCat
    FrostCat:

    WTFer:
    I have found GUIDs pretty useful when the objects are created by different people in different places (for example, a sales database where new records are added from an offline laptop and need to sync with the server).  Specially if the objects or entities are build offline, so you know the ID's will never crash. Thus making this a WTF, since these GUIDs don't have the properties associated with real GUIDs and gives you no extra security against id crashing than using a simple autonumbered int.
    --Mexican, really sorry for the broken english

     

    Man, that's totally the point of GUIDs--to create "references" that are more or less guaranteed not to collide with GUIDs created on other computers.

    Note that if you are running Windows without a NIC, the last 6 bytes of any generated GUIDs using the MS tools that ship with Visual Studio will always be the same, so it's theoretically more likely to have collisions.  Of course, when you're dealing with 10**<super>38</super>, what's a couple of orders of magnitude among friends?



    Hmm, interesting. So erm, what would this value be?
     * Anonymous looks though all the GUID's and laughs at the poor developers without NIC's
  • (cs) in reply to Perry Pederson
    Anonymous:

    From http://en.wikipedia.org/wiki/GUID:

    Each generated GUID is "mathematically guaranteed" to be unique.



    Thanks for reminding me, I've been meaning to change that.  HHOS.
  • (cs) in reply to chep
    Anonymous:

    What is wrong with empty guid as a NULL-equivalent value for a value-type? How to say "undefined" in C# for Guid without using Empty?



    Guid guid = null;  // why not?

    BTW, I just have to chime in on the PascalCase thing.  camelCase isEasyToRead evenWithWtfAcronyms, but_lower_case_with_underscores is easy to read, too.  I was a C programmer for years, and thought camelCaseWasHideous, but after using Java for a while I realize it's just a matter of what you're used to.

    PeopleWhoUsePascalCase (for methods) should be shot, however.  Oh, and IWhat is the IDeal with IInterfaces IBeginning with I?  Unless you're defining an interface for a type that can lead a slave rebellion and want to call it ISpartacus, please leave the gdHungarian where it belongs, in the ashheap of code history.

Leave a comment on “Call Me {F2A94419-12AD-4244-87F2-F1D7D21997F6}.”

Log In or post as a guest

Replying to comment #:

« Return to Article