Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
McGlockenshire
Dec 16, 2005

GOLLOCKS!

wwb posted:

Oh, and who the gently caress submitted that xjson poo poo to reddit.

Karma is a hell of a drug.

Adbot
ADBOT LOVES YOU

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
ahh christ do they not understand anything about xml

here's how you represent arbitrary json in xml, assholes:

pre:
{
  "name":"John Smith"
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": 10021,
  },
  "phoneNumbers": [
    "212 555-1111",
    "212 555-2222"
  ],
  "additionalInfo": null,
  "remote": false,
  "height": 62.4,
  "ficoScore": " > 640"
}
pre:
<?xml version="1.0" encoding="UTF-8"?>
<object xmlns="urn:json-xml">
  <string key="name" value="John Smith"/>
  <object key="address">
    <string key="streetAddress" value="21 2nd Street"/>
    <string key="city" value="New York"/>
    <string key="state" value="NY"/>
    <string key="postalCode" value="10021"/>
  </object>
  <array key="phoneNumbers">
    <string value="212 555-1111"/>
    <string value="212 555-2222"/>
  </array>
  <null key="additionalInfo"/>
  <bool key="remote" value="false"/>
  <number key="height" value="62.4"/>
  <string key="ficoScore" value="&gt; 640"/>
</object>
Yes, it's more verbose. There's no avoiding that -- any time you wrap one format in another it'll be ugly. But it doesn't have to be *horridly* verbose.

Perhaps IBM's customers are paying by the byte.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Doc Hawkins posted:

Why? Because Enterprise!

y'see, JSON doesn't scale. I know this, you know this, everyone knows this. It's a fact.

XML? XML Scales. Like. A. BOSS.

Sedro
Dec 31, 2008

Janin posted:

ahh christ do they not understand anything about xml

here's how you represent arbitrary json in xml, assholes:

It's a horrible idea, but their execution was fine. The namespace clutter is clearly because the xml was generated. Your example is inconsistent since you use both a "value" attribute and the "value" of the element.

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


Janin posted:

Perhaps IBM's customers are paying by the byte.

It's typical enterprise, no one wants to bother selling small, simple jobs, so the providers make the most over-complicated spec they can that they can still get accepted by the client.

Sewer Adventure
Aug 25, 2004
DataPower®

Volte
Oct 4, 2004

woosh woosh
I think maybe that IBM JSON thing is because whatever that web service is, it works with XML internally, but can interoperate with JSON externally. So clients can send JSON to it and it will work transparently. At least that's the impression I got. It's ugly, but interop usually is.

Zombywuf
Mar 29, 2008

Volte posted:

I think maybe that IBM JSON thing is because whatever that web service is, it works with XML internally, but can interoperate with JSON externally. So clients can send JSON to it and it will work transparently. At least that's the impression I got. It's ugly, but interop usually is.

All that happens here is the mechanism to turn the flat text into a tree changes, for both JSON and XML these are solved problems. The hard bit is doing something useful with this tree, which this does not help with. It's a classic bit of busy work.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Doc Hawkins posted:

It's typical enterprise, no one wants to bother selling small, simple jobs, so the providers make the most over-complicated spec they can that they can still get accepted by the client.

I had direct experience with this once. Someone came to our company with a job, they wanted some word documents transformed into an XML format. The docs were mostly consistent with themselves, but between docs there were some differences.

I looked at the project and thought "This is a job for a couple Perl scripts written to get most of the job done and then some manual steps." A little dirty, sure, but it is just parsing text anyway. I figured it'd take a week or two.

At the time I wasn't officially a dev, so first the dev team put in their design. They wanted to charge some 200+ hours to write this ridiculous C# tool that would magically be able to transform any document into anything else. I did not ingratiate myself with that developer when I came into the meeting with my 40-60 hour estimate and also questioned whether the tool he was proposing would even solve the problem.

I mean, if you write a generic tool like that, congratulations, you've reinvented awk. Now you have to write a config file for each document and we're right back where we started.

I also didn't think he was even close to capable of writing the thing he described. When told to write unit tests for an app, he added code to button handlers to output log messages if a debugger was attached saying that the buttons had been clicked.

Impotence
Nov 8, 2010
Lipstick Apathy
Wouldn't it just be easier to resave the word document as .docx and unzip it

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Sedro posted:

It's a horrible idea, but their execution was fine. The namespace clutter is clearly because the xml was generated. Your example is inconsistent since you use both a "value" attribute and the "value" of the element.
My example is perfectly consistent. XML elements do not have values, only children, so it's perfectly natural to list the content of JSON arrays and objects as child elements.

Generated XML is no excuse for choosing such verbose namespaces and prefixes. If it absolutely *must* have prefixes, the generator should at least just use "j:".

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Janin posted:

My example is perfectly consistent. XML elements do not have values, only children, so it's perfectly natural to list the content of JSON arrays and objects as child elements.

Generated XML is no excuse for choosing such verbose namespaces and prefixes. If it absolutely *must* have prefixes, the generator should at least just use "j:".
but what if they also need to interoperate with a J<->XML system

Gough Suppressant
Nov 14, 2008
Reading through the gigantic backlog. This thread is basically a zoo where both sides of the glass paid to get in and look at the other.

darkhand
Jan 18, 2010

This beard just won't do!

MonsterUnderYourBed posted:

Reading through the gigantic backlog. This thread is basically a zoo where both sides of the glass paid to get in and look at the other.

Haha, that's a really good analogy and I'm going to have to start using that more often in real life.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Aleksei Vasiliev posted:

but what if they also need to interoperate with a J<->XML system
Add a second prefix to "urn:j-xml", duh

qntm
Jun 17, 2009

Janin posted:

Perhaps IBM's customers are paying by the byte.

Paying by the processor cycle is actually closer to the truth.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Janin posted:


Perhaps IBM's customers are paying by the byte.

IBM owns our EDI VAN provider (EDI being another overwrought overdesigned unreadable flat file specification) and they charge us by the byte. Wouldn't surprise me if that's true.

Zombywuf
Mar 29, 2008

Scaramouche posted:

IBM owns our EDI VAN provider (EDI being another overwrought overdesigned unreadable flat file specification) and they charge us by the byte. Wouldn't surprise me if that's true.

The EDI based XML I've seen looks mostly like this:
code:
<xml>AUOIIE  9828309 X-XAEUAOEUU23cdl23c4f13c23---Q-AE-</xml>
Now that's how you save bytes in an XML encoding.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Zombywuf posted:

The EDI based XML I've seen looks mostly like this:
code:
<xml>AUOIIE  9828309 X-XAEUAOEUU23cdl23c4f13c23---Q-AE-</xml>
Now that's how you save bytes in an XML encoding.

Yeah, mine's all flat file so it looks a bit more exploded/bizarre text file than that. What's funny is some of the partners use the old spec that insists the ascii flat file actually has reserved white space. So if field A can contain a max 16 characters you better believe that it's going to look like:
code:
REF*          123456*
and so on. Really pushes those bytes up.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Scaramouche posted:

Yeah, mine's all flat file so it looks a bit more exploded/bizarre text file than that. What's funny is some of the partners use the old spec that insists the ascii flat file actually has reserved white space. So if field A can contain a max 16 characters you better believe that it's going to look like:
code:
REF*          123456*
and so on. Really pushes those bytes up.

PIC X(16)

I've worked on some COBOL ERPs and they pull that dogshit all the time. Have to trim() every single data element you get.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

TRex EaterofCars posted:

PIC X(16)

I've worked on some COBOL ERPs and they pull that dogshit all the time. Have to trim() every single data element you get.

Sad part is even though we say we use the 4011 spec there's all kinds of little exceptions to the mapper. Some guys will provide *0000000000123456~, some the above, some don't care so it's *123456~ etc. Thank goodness the spec itself is relatively strong when it comes to typing so I don't have to test for number/bit/string/ness all the time.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
All this talk reminds me of all the various NENA file formats I have to work with all the time. I think there's something like 9 different data formats for ALI/location data, and the fields don't seem to map cleanly between any of them. Some of them are fixed/flat format, while some are XML.

The format I'm specifically working with today is a 512-character record format, with all fields padded with spaces on the right, except one field, that's padded on the left. There are over 100 characters of 'reserved' (i.e., blank) fields as well.

NotShadowStar
Sep 20, 2000
I'm getting the impression that XML is the greatest common denominator of enterprise communication horseshit because you can actually understand what the data is, but it's the least common denominator on people who just want to get poo poo done.

Voronoi Potato
Apr 4, 2010
I have to maintain a 750,000 line vba project full of gotos. The horror I saw today?


code:
Dim CNullString as string
CNullString = "nUlLsTrInG" 
The variable name was something like strCNull or some equivalent, but the value just left me baffled.

"nUlLsTrInG" What is this SQUIGGLECASE. I must admit I am just a lowly code janitor but this seems really :supaburn: batshit insane.

Why? Why would you have a nullstring constant? Why would you have it hold a value? wHy WoUlD tHaT vAlUe hAvE tHiS gOiNg On?

pseudorandom name
May 6, 2007

Presumably nobody will ever set a string to "nUlLsTrInG", in which case any string which is "nUlLsTrInG" must be the null string.

Voronoi Potato
Apr 4, 2010

pseudorandom name posted:

Presumably nobody will ever set a string to "nUlLsTrInG", in which case any string which is "nUlLsTrInG" must be the null string.

cool but why not use vbNullString, or "" or y'know the faster if lenB(str) = 0 ? There is no way in hell that is really how you are supposed to do it.

bobthecheese
Jun 7, 2006
Although I've never met Martha Stewart, I'll probably never birth her child.
Maybe, you legitimately want to store an empty string. Maybe you want to throw an error if the string is null, though. Maybe, just MAYBE, there might be justification for doing that.

Probably not, though.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

MonsterUnderYourBed posted:

Reading through the gigantic backlog. This thread is basically a zoo where both sides of the glass paid to get in and look at the other.
The question is: what causes coding horrors? The answer is: software engineers.

pr0metheus
Dec 5, 2010

bobthecheese posted:

Maybe, you legitimately want to store an empty string. Maybe you want to throw an error if the string is null, though. Maybe, just MAYBE, there might be justification for doing that.

Probably not, though.

Maybe author needed a special case for an string value in code that is not quite same as actual null string, and that variable name is just a bad choice of words?

sklnd
Nov 26, 2007

NOT A TRACTOR

Mustach posted:

The question is: what causes coding horrors? The answer is: software engineers.

We should ban all Software Engineers to put an end to coding horrors.

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

sklnd posted:

We should ban all Software Engineers to put an end to coding horrors.

It's the Software Architects you've got to worry about. They decide that because it makes a pretty picture it's a working design.

Apologies to any Software Architects who worked their way up from programmer.

Zombywuf
Mar 29, 2008

pr0metheus posted:

Maybe author needed a special case for an string value in code that is not quite same as actual null string, and that variable name is just a bad choice of words?

VB has three kinds of null already, clearly that was not enough for this code's author.

deedee megadoodoo
Sep 28, 2000
Two roads diverged in a wood, and I, I took the one to Flavortown, and that has made all the difference.


arvash posted:

Why? Why would you have a nullstring constant? Why would you have it hold a value? wHy WoUlD tHaT vAlUe hAvE tHiS gOiNg On?

To gently caress with your head.

Edison was a dick posted:

It's the Software Architects you've got to worry about. They decide that because it makes a pretty picture it's a working design.

Apologies to any Software Architects who worked their way up from programmer.

Architects aren't exempt just because they came from the trenches. The last great horror I witnessed came from an architect who worked his way up through the company as a programmer. He was really great writing code but he couldn't understand what kind of hell he was unleashing on the people who maintained the app in production.

Also, architects from a software background usually have less of an understanding of how to do things without jumping through a ton of hoops. Example: the project I am currently working on is a "messaging gateway" which just sends messages to the appropriate application to be processed. Instead of engineering an entirely new solution we could have just set up an irule on the F5 to automatically route the messages. And if they needed manipulation or translation we could have easily used an out of the box solution like mule instead of engineering something ourselves. In my experience architects from a software engineering background want to write everything either because A) "I can do it better" or B) "I didn't know that existed" and in both cases it ends up a disaster*.

*enterprise

deedee megadoodoo fucked around with this message at 15:53 on May 3, 2011

Amtiskaw
May 15, 2003

it was almost the longest
Just found this in some guy's code I'm rewriting.
code:
int draggableCount = _active.Where(t => t.IsItemDraggable == Boolean.Parse("false")).Count();
if (draggableCount > 0)
{
    errorMessage = "This transaction cannot be assigned as it has already been processed";
}
There's pages of this poo poo to wade through. In work I have a reputation as some kind of crazy perfectionist because I don't think code like is good enough.

ninjeff
Jan 19, 2004

Amtiskaw posted:

Just found this in some guy's code I'm rewriting.
code:
int draggableCount = _active.Where(t => t.IsItemDraggable == Boolean.Parse("false")).Count();
if (draggableCount > 0)
{
    errorMessage = "This transaction cannot be assigned as it has already been processed";
}
There's pages of this poo poo to wade through. In work I have a reputation as some kind of crazy perfectionist because I don't think code like is good enough.

If you're referring to the filter, that's not that bad; he was probably in the middle of refactoring it from when IsItemDraggable was a string or something, and got called to work on something else.

Other than that it's just not great code (why does having a positive draggableCount mean that the transaction has already been processed?), but not really a horror IMO.

Tell him he should use .Any(), by the way.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

ninjeff posted:

If you're referring to the filter, that's not that bad; he was probably in the middle of refactoring it from when IsItemDraggable was a string or something, and got called to work on something else.

Other than that it's just not great code (why does having a positive draggableCount mean that the transaction has already been processed?), but not really a horror IMO.

Tell him he should use .Any(), by the way.

I'm glad I'm not the only one. It's not pretty, but to my amateur self it didn't seem like a horror.

nielsm
Jun 1, 2009



Well if nothing else, having some UI state of something indicate a data state, and be the only (or best) way of checking for that data state, is a maintainability-problem brewing. This could also point to the controller leaking into the view, or something to that effect.

IsItemDraggable should depend on IsTransactionProcessed, not the other way.

Amtiskaw
May 15, 2003

it was almost the longest
The horror was the parsing of a string literal to bool to compare to a bool, plus the use of where + count to achieve what can be done with another standard operator.

code:
if (_active.Any(t => !t.IsItemDraggable))
{
    errorMessage = "This transaction cannot be assigned as it has already been processed";
}
The IsItemDraggable name is from the service we're using btw, so not that guy's fault. But I can guarantee the rest wasn't a result of him refactoring anything. He just has a habit of doing simple things in the most tortuous way possible, and trying to use stuff like Linq without really understanding it properly.

For example, we're using MVVM, so we have a view model that I put observable properties on. And some of the property setters have some logic in them to mutate related properties, fire notification events etc. Well this guy has seen this, and decided it means everything should be done via logic in property setters.

So instead of having say, a method called SubmitTransactions(t), he has a property like this

code:
private ObservableCollection<Transaction> _submittedTransactions

public ObservableCollection<Transaction> SubmittedTransactions
{
    get { return _submittedTransactions; }
    set
    {
        _submittedTransactions = value;
       
        ...100 lines of logic to submit the new values to a web service
    }
}
And of course, the property is never read from anywhere, it's just set.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Amtiskaw posted:

The horror was the parsing of a string literal to bool to compare to a bool, plus the use of where + count to achieve what can be done with another standard operator.

Seriously this should be ringing alarm bells in your head. That is some amateur hour poo poo that only first semester students do.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Amtiskaw posted:

The horror was the parsing of a string literal to bool to compare to a bool,

Hah! I skimmed right over that.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply