• Anonymous (unregistered)
  • the beholder (unregistered)

    A senior is the right choice. You wouldn't want to bestow this mess upon a guy that is still far from retirement.

    And no frist for you

  • (cs)

    I see that Chris B's predecessor thought that he'd use regular expressions to turn one problem into (at least) 12… With bonus enterpriseyness from all that XML too.

  • (cs)

    Obligitory comment about regex and the number of problems rising exponentially because of it.

    edit: damn you dkf :p

  • verisimilidude (unregistered)

    And if I disable sending of the user agent string does that make me a secret agent?

  • (cs) in reply to verisimilidude
    verisimilidude:
    And if I disable sending of the user agent string does that make me a secret agent?
    No it makes you a hidden agent.
  • TroelsL (unregistered)

    This solution needs more service oriented architecture to facilitate social discovery.

  • foo (unregistered) in reply to PiisAWheeL
    PiisAWheeL:
    verisimilidude:
    And if I disable sending of the user agent string does that make me a secret agent?
    No it makes you a hidden agent.
    Obviously part of a sleep()er cell.
  • Kryptus (unregistered)

    I can see that a UserAgentParser.java is missing... and a bunch of hundreds more classes of course.

  • Kasper (unregistered)

    The real WTF is the UnsupportedUserAgentException.

  • Rfoxmich (unregistered)

    Wonder what the lynx configuration file looks like

  • CAPTCHA:abigo (unregistered) in reply to PiisAWheeL
    PiisAWheeL:
    verisimilidude:
    And if I disable sending of the user agent string does that make me a secret agent?
    No it makes you a hidden agent.
    So I guess browsers that insist on sending the names of two different browsers ("Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)") must be double agents.

    (Admire the beauty of my string literal parenthization!)

  • Iscu (unregistered)
  • uns (unregistered) in reply to TroelsL
    TroelsL:
    This solution needs more service oriented architecture to facilitate social discovery.

    UserAgendParsedLetsPostToTwitterAboutIt.class ?

  • (cs)

    Someone clearly needs to create a SaaS user-agent detection infrastructure to harness the power of the cloud and synergize the relationship between browsers and content-authoring and delivery systems.

  • (cs) in reply to Strolskon
    Strolskon:
    Someone clearly needs to create a SaaS user-agent detection infrastructure to harness the power of the cloud and synergize the relationship between browsers and content-authoring and delivery systems.
    With a comment like that my guess is that you work in a marketing department somewhere.
  • (cs) in reply to uns
    uns:
    TroelsL:
    This solution needs more service oriented architecture to facilitate social discovery.

    UserAgendParsedLetsPostToTwitterAboutIt.class ?

    Your User Agent is: "Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120403211507 Firefox/12.0".

    [image]
  • db (unregistered)

    I'm not sure if I get it right.

    The Firefox XML takes care of parsing and hence the wonder "why have so many classes and interfaces?"

  • WTF-land braver (unregistered) in reply to the beholder
    the beholder:
    A senior is the right choice. You wouldn't want to bestow this mess upon a guy that is still far from retirement.
    I agree. Work too long on this crap and you'll end up insane
  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to Anonymous
    Anonymous:
    You posted the wrong Bill... [image]
  • Kasper (unregistered) in reply to CAPTCHA:abigo
    CAPTCHA:abigo:
    So I guess browsers that insist on sending the names of two different browsers ("Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)") must be double agents.
    According to the protocol specification, the part in parenthesis is just a comment, which doesn't actually identify anything. So above user agent contains only one browser name, which is Mozilla/5.0. That is not to say it actually is Mozilla/5.0, it might be some other browser spoofing a Mozilla/5.0 user-agent header.
  • adiener (unregistered)

    I feel physically ill after reading this. Seriously.

  • Tim B-L (unregistered)

    The web is about connecting everything to everything, and everyone to everyone.

    If you're even looking at the User Agent string you're doing it wrong!

  • (cs)

    Hm... could it be that all those Java classes and interfaces are actually a generated XML binding?

    That would make it a bit less of a WTF: Someone thought that right way to approach this was to pour all knowledge about user agent strings into XML configuration files (to make it, you known, configurable! Yay for Softcoding!), then defined a schema for that and used a binding generator.

    Yeah, it's still a pretty dumb way to do it.

  • Larry (unregistered)

    When all you have is a hammer, everything looks like a nail.

    When all you have is an XML-autogenerated-Java lasagna architecture, everything looks like an enterprise!

  • (cs) in reply to Iscu
    Iscu:
    You know, I actually like Java and am pretty sick of all the cheap bashing, but this is just too damn funny (and too often true).
  • Myself (unregistered)

    Guys, you are all missing the point. Imagine you are a consultant who wants to squeeze out a couple of extra paid weeks but the project is almost done. You convince the customer that you need of course to figure out the user agent for customized UI rendering. Everybody knows that!!!! You could probably do that in a couple of hours but you need the money so you try to find out how much bloat you could create for simple string parsing. A bit like the "1+1=2 in scientific representation" joke. Either that or Chris B work at IBM.

  • Jay (unregistered) in reply to CAPTCHA:abigo
    CAPTCHA:abigo:
    PiisAWheeL:
    verisimilidude:
    And if I disable sending of the user agent string does that make me a secret agent?
    No it makes you a hidden agent.
    So I guess browsers that insist on sending the names of two different browsers ("Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)") must be double agents.

    (Admire the beauty of my string literal parenthization!)

    I thought a Double agent was the opposite of an Integer agent.

  • Jay (unregistered) in reply to PiisAWheeL
    PiisAWheeL:
    Strolskon:
    Someone clearly needs to create a SaaS user-agent detection infrastructure to harness the power of the cloud and synergize the relationship between browsers and content-authoring and delivery systems.
    With a comment like that my guess is that you work in a marketing department somewhere.

    You need to add something about "utilizing paradigms".

  • YF (unregistered)

    I needed to do browser discovery for logging purposes only, but I'm not skilled enough to create this masterpiece...

    ...so I just coded this in Java: http://www.quirksmode.org/js/detect.html

    Time consumed: ~1h

    Fail?

  • big picture thinker (unregistered) in reply to Tim B-L
    Tim B-L:
    The web is about connecting everything to everything, and everyone to everyone.

    If you're even looking at the User Agent string you're doing it wrong!

    The User Agent String is essential to check to determine what content to send.

    You wouldn't want to send a full desktop-based website (800+ pixel wide screen) with high resolution images to an Android or iPhone, would you?

    It's also useful in serving correct CSS. You don't necessarily have to put hacks in your CSS if you simply send a different stylesheet for msie than for gecko/webkit.

  • J (unregistered) in reply to YF
    YF:
    I needed to do browser discovery for logging purposes only, but I'm not skilled enough to create this masterpiece...

    ...so I just coded this in Java: http://www.quirksmode.org/js/detect.html

    Time consumed: ~1h

    Fail?

    Yes. That code can't detect the Android browser. It calls it 'Mozilla'.

  • apoc9 (unregistered)

    It's nice when someone re-implements SDK Collection, Pattern, Properties, String, Boolean. Plus cache, because we need optimization.

  • apoc9 (unregistered) in reply to YF
    YF:
    I needed to do browser discovery for logging purposes only, but I'm not skilled enough to create this masterpiece...

    ...so I just coded this in Java: http://www.quirksmode.org/js/detect.html

    Time consumed: ~1h

    Fail?

    [image] Sorry to bring it to you JavaScript != Java.

  • Ken B. (unregistered) in reply to big picture thinker
    big picture thinker:
    Tim B-L:
    The web is about connecting everything to everything, and everyone to everyone.

    If you're even looking at the User Agent string you're doing it wrong!

    The User Agent String is essential to check to determine what content to send.
    Why do you feel the need to send different content to different user agents? I've seen websites that refuse to serve up anything to "wget" unless I tell it to pretend to be something else.

    You wouldn't want to send a full desktop-based website (800+ pixel wide screen) with high resolution images to an Android or iPhone, would you?
    Ah... You want to have a "mobile" version? Use CSS.
    It's also useful in serving correct CSS. You don't necessarily have to put hacks in your CSS if you simply send a different stylesheet for msie than for gecko/webkit.
    Oh, so you know about using CSS for this? Given that the browser already knows what type of browser it is, along with the destination media, why not let it pick the correct CSS, rather than writing such ugly things that try to parse every possible (and every future) user agent string? Yes, you sometimes need to use CSS hacks to handle "broken" browsers, but those have already been written in clear, concise forms.
  • Tim B-L (unregistered) in reply to big picture thinker
    big picture thinker:
    Tim B-L:
    The web is about connecting everything to everything, and everyone to everyone.

    If you're even looking at the User Agent string you're doing it wrong!

    The User Agent String is essential to check to determine what content to send.

    You wouldn't want to send a full desktop-based website (800+ pixel wide screen) with high resolution images to an Android or iPhone, would you?

    It's also useful in serving correct CSS. You don't necessarily have to put hacks in your CSS if you simply send a different stylesheet for msie than for gecko/webkit.

    If you're counting pixels you're doing it wrong! A user-agent should be able to resize images so they fit, or let you scroll. Your HTML should also be able to resize so it fits. If it can't, please go shoot yourself now for me, please please!!! YOU ARE THE PROBLEM!!!!!!!!

  • (cs) in reply to Tim B-L
    Tim B-L:
    If you're counting pixels you're doing it wrong! A user-agent should be able to resize images so they fit, or let you scroll. Your HTML should also be able to resize so it fits. If it can't, please go shoot yourself now for me, please please!!! YOU ARE THE PROBLEM!!!!!!!!
    [image]
  • XMLBasher (unregistered)

    XML is like violence. If it's not solving all your problems, you're not using enough of it.

  • bad_management (unregistered) in reply to Myself

    No! Management where I work insist on "1+1>2". They literally told us that in a presentation! So your argument is invalid.

  • (cs) in reply to bad_management
    bad_management:
    No! Management where I work insist on "1+1>2". They literally told us that in a presentation! So your argument is invalid.

    For large values of 1 it does... 1.4+1.4=2.8 rounded off to integers 1+1=3

  • (cs) in reply to YF

    You're using Safari 5 on an unknown OS!

    lovely

  • (cs) in reply to J
    J:
    YF:
    I needed to do browser discovery for logging purposes only, but I'm not skilled enough to create this masterpiece...

    ...so I just coded this in Java: http://www.quirksmode.org/js/detect.html

    Time consumed: ~1h

    Fail?

    Yes. That code can't detect the Android browser. It calls it 'Mozilla'.

    And today's lesson is, don't show your code around here with pride, it'll be bashed to ashes.

  • (cs)

    This is obviously utterly ridiculous, and its creation was a massive waste of time, with benefits nowhere near justified by its cost.

    But were I developing something on top of it, it looks like it'd be pretty handy!

  • (cs)

    Pretty dumb in my book, how are you supposed to add new browsers? I would have used regex to parse the user string, send that off to an MSSQL database (must be version 6.32532.32533 because it relies on an obscure bug that only exists in this exact version), and then a series of stored procedures will compare each bit of the user string and compare it to every bit of information in the database. Once it determines if the user is using Internet Explorer (can't use other browsers, takes too long to populate the database by hand) it gets wrapped up in XML and sent back to be regexed again and then a for loop runs through each entry in the database and compares it against the parsed data.

  • x (unregistered) in reply to Tim B-L
    Tim B-L:
    If you're counting pixels you're doing it wrong! A user-agent should be able to resize images so they fit, or let you scroll. Your HTML should also be able to resize so it fits. If it can't, please go shoot yourself now for me, please please!!! YOU ARE THE PROBLEM!!!!!!!!
    Amazingly, HTML can be used for things other than web pages.
  • Nails on a chalkboard (unregistered)

    Reminds me of "Enterprise FizzBuzz" http://codermike.com/if-something-is-worth-doing

  • Gunslinger (unregistered) in reply to x
    x:
    Tim B-L:
    If you're counting pixels you're doing it wrong! A user-agent should be able to resize images so they fit, or let you scroll. Your HTML should also be able to resize so it fits. If it can't, please go shoot yourself now for me, please please!!! YOU ARE THE PROBLEM!!!!!!!!
    Amazingly, HTML can be used for things other than web pages.

    Name an application that requires pixel-counting.

  • x (unregistered) in reply to Gunslinger
    Gunslinger:
    x:
    Tim B-L:
    If you're counting pixels you're doing it wrong! A user-agent should be able to resize images so they fit, or let you scroll. Your HTML should also be able to resize so it fits. If it can't, please go shoot yourself now for me, please please!!! YOU ARE THE PROBLEM!!!!!!!!
    Amazingly, HTML can be used for things other than web pages.

    Name an application that requires pixel-counting.

    One for which I am responsible. Some applications run in the context of other applications, and therefore do not have the luxury of defining how they may be constructed. In this case, UI is done in HTML, but that doesn't change the specs.

  • smilr (unregistered) in reply to big picture thinker
    big picture thinker:
    You wouldn't want to send a full desktop-based website (800+ pixel wide screen) with high resolution images to an Android or iPhone, would you?

    Please stop making websites.

    I specifically jailbroke my iOS devices so that I can put in the UAFaker addon to mobilesafari specifically so I can claim to be a desktop browser in order to prevent what you advocate.

    I have zooming / panning capabilities in my mobile browser that permit me to efficiently view the normal or desktop versions of websites. I prefer them to the "mobile" stripped down versions of websites.

    When in ladscape mode my screen resolution is above 800px wide anyhow and my eyesight is good enough that I can usually read text rendered that small on my phone's screen, and zoom in when necessary anyhow.

    Stop dumbing down the internet. Damnum

  • Aussie Contractor (unregistered) in reply to smilr
    smilr:
    big picture thinker:
    You wouldn't want to send a full desktop-based website ..... with high resolution images to an Android or iPhone .....
    ..... I have zooming / panning capabilities in my mobile browser that permit me to efficiently view the normal or desktop versions of websites. I prefer them to the "mobile" stripped down versions of websites.....

    My web apps all have a mobile version detected by the server.

    The download size to fully display a page in the "desktop" version is 125kb and on the "mobile" version it is <2kb. When you are standing 450Km from the nearest town using my app on your Nokia 6550 you will thank me.

    Oh, and don't worry about modding the OS on your phone and install any special app, there is a link at the bottom which says "Show Desktop Site"

    And for the record I use a script from here which took 3 minutes to implement. I wish I had billed a client 3 weeks and created the masterpiece above.

Leave a comment on “The Enterprise User Agent”

Log In or post as a guest

Replying to comment #:

« Return to Article