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
necrotic
Aug 2, 2005
I owe my brother big time for this!

eithedog posted:

There's this: http://json-schema.org/, but as far as the W3C drafts go, I think this is the only mention: http://www.w3.org/community/odrl/work/json/ (http://tools.ietf.org/html/draft-zyp-json-schema-04)

There're also YAML-related schemas - http://www.kuwata-lab.com/kwalify/ / http://rx.codesimply.com/, but again - nothing official.

We're starting to use JSON (Hyper) Schema at work. It's like SOAP all over again, only with JSON :haw:

The ability to consume a document and have an API client is really nice though as we start migrating to micro services. Although as we change communication protocols (currently all simply HTTP, but we're moving to some kind of bus) I'm not sure how it will work.

Adbot
ADBOT LOVES YOU

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

necrotic posted:

We're starting to use JSON (Hyper) Schema at work. It's like SOAP all over again, only with JSON :haw:

The ability to consume a document and have an API client is really nice though as we start migrating to micro services. Although as we change communication protocols (currently all simply HTTP, but we're moving to some kind of bus) I'm not sure how it will work.

Kind of the wrong thread I know but what does a SOAP header actually provide? I always find it an annoyance, and I fail to see one useful thing it does that standard XML doesn't. I don't work with XML very often though so I don't have more than a glancing knowledge of pretty much what it looks like and a little bit of WPF stuff.

Vanadium
Jan 8, 2005

Zamujasa posted:

XML is nothing compared to the billion "I saw something using XML so I copied what it looked like" pseudo-XML files out there.

Just because you wrap values in angle brackets does not mean you are using XML :argh:

How do I tell whether I'm doing XML right, then?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Vanadium posted:

How do I tell whether I'm doing XML right, then?

Can you redefine id?

Westie
May 30, 2013



Baboon Simulator

Vanadium posted:

How do I tell whether I'm doing XML right, then?

Does a simple tuple with 1000 rows take up 1mb of hard disk space?

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Knyteguy posted:

Kind of the wrong thread I know but what does a SOAP header actually provide? I always find it an annoyance, and I fail to see one useful thing it does that standard XML doesn't. I don't work with XML very often though so I don't have more than a glancing knowledge of pretty much what it looks like and a little bit of WPF stuff.

SOAP with a WSDL that describes your API means someone can autogenerate methods in whatever language they want that knows how to talk to that API. Exposes the methods & data types, what not. When it works, it's a huge time saver. Put in (url to) WSDL and out comes a bunch of source files that you can include in your project.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Vanadium posted:

How do I tell whether I'm doing XML right, then?
Validate it against a schema. If it doesn't validate, you're not doing XML right. If you don't have a schema, you're definitely not doing XML right, because schemas are the main reason to use XML.

Vanadium
Jan 8, 2005

Update: I'm not doing xml right.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Vanadium posted:

Update: I'm not doing xml right.

Bullet dodged.

Germstore
Oct 17, 2012

A Serious Candidate For a Serious Time
The proper way to do xml:

code:
<row><field><kvpair><key>id</key><value>1234</value></kvpair></field><field><kvpair><key>name</key><value...

Literally Elvis
Oct 21, 2013

crosspost from the noob jobs thread:
The Fizz Buzz from Outer Space

quote:

Matteo recently interviewed a candidate that was employed elsewhere as an “architect”. His responses to the standard soft-skills questions sounded a bit rehearsed, which made Matteo suspicious, so he started asking some more technical questions, like: “What’s the difference between an interface and an abstract class?”

“Well, in some logarithms , an interface is going to be internal to the system, but an abstract class has terminators that make it external.”

Matteo almost showed him the door right there, but that might just be nerves or a misunderstanding. Instead, Matteo broke out the trust old interviewing tool- the FizzBuzz.

“So, the program should print numbers, but if the number is divisible by three, it should print ‘fizz’, and if it’s divisible by five it should print ‘buzz’, and if it’s divisible by both, it should print ‘fizz buzz’. I can do that.”

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Literally Elvis posted:

crosspost from the noob jobs thread:
The Fizz Buzz from Outer Space

Sounds just like the architects at my company.

TheresaJayne
Jul 1, 2011

Literally Elvis posted:

crosspost from the noob jobs thread:
The Fizz Buzz from Outer Space

I read the comments, I loved this one - reminds me of previous roles....

quote:

FizzBuzzFactoryBeanFactoryBeanManagerBeanFactoryBeanBeanFactory

Westie
May 30, 2013



Baboon Simulator

TheresaJayne posted:

I read the comments, I loved this one - reminds me of previous roles....

from my memory and the comments it seems:

https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

ShadowHawk
Jun 25, 2000

CERTIFIED PRE OWNED TESLA OWNER

TheresaJayne posted:

I read the comments, I loved this one - reminds me of previous roles....

I felt inspired to write this:
Python code:
#!/usr/bin/env python3
with open('runner.py', 'w') as f:
    f.write('#!/usr/bin/env python3\n')
    f.write('for x in range(1, 101):\n')
    f.write('    if (x == 0): print("fizzbuzz")\n')
    fizziness = 0
    barriness = 0
    for var in range(1, 101):
        fizziness += 1
        barriness += 1
        if fizziness == 3 and barriness == 5:
            fizziness = 0
            barriness = 0
            f.write('    elif (x == %s): print("fizzbuzz")\n' % var)
        elif fizziness == 3:
            fizziness = 0
            f.write('    elif (x == %s): print("fizz")\n' % var)
        elif barriness == 5:
            barriness = 0
            f.write('    elif (x == %s): print("buzz")\n' % var)
        else:
            f.write('    elif (x == %s): print(x)\n' % var)

import runner

canis minor
May 4, 2011

ShadowHawk posted:

I felt inspired to write this:
Python code:
#!/usr/bin/env python3
with open('runner.py', 'w') as f:
    f.write('#!/usr/bin/env python3\n')
    f.write('for x in range(1, 101):\n')
    f.write('    if (x == 0): print("fizzbuzz")\n')
    fizziness = 0
    barriness = 0
    for var in range(1, 101):
        fizziness += 1
        barriness += 1
        if fizziness == 3 and barriness == 5:
            fizziness = 0
            barriness = 0
            f.write('    elif (x == %s): print("fizzbuzz")\n' % var)
        elif fizziness == 3:
            fizziness = 0
            f.write('    elif (x == %s): print("fizz")\n' % var)
        elif barriness == 5:
            barriness = 0
            f.write('    elif (x == %s): print("buzz")\n' % var)
        else:
            f.write('    elif (x == %s): print(x)\n' % var)

import runner

The OCD in me is sad that it's not buzziness

PrBacterio
Jul 19, 2000

Zamujasa posted:

XML is nothing compared to the billion "I saw something using XML so I copied what it looked like" pseudo-XML files out there.

Just because you wrap values in angle brackets does not mean you are using XML :argh:
That's actually the worst part about XML, yes, but I'd argue that it's a flaw of XML itself. I've seen this happen way too many times, with the people doing it refusing to back down even when called out on it -- "what? you're writing your own XML parser? have fun implementing all the details of that convoluted several-hundred-pages standards document - oh, you're not? well then it's not really XML, is it? -- 'stop bothering me, sperg, it too is XML! it uses angle brackets, see! just because I don't follow the standard doesn't mean it isn't XML, anything that uses angle brackets is XML and if you disagree you're a sperg, you sperg!!!'".

EDIT: What really bothers me about this is that in all of these cases, the people involved would have been better served to just use a simple ini-file style text file to store their key-value pairs or, if they just HAD to use XML for whatever reason, to just pick any of the vast number of existing XML libraries out there and use that but no, they just had to go and write their own (typically regexp-based) angle-bracket parser and call that bit of cargo cult programming "XML."

PrBacterio fucked around with this message at 15:34 on Sep 4, 2014

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:
If you make the same off-by-one error on both sides of a comparison, is it still an error?

code:

bool isInRange = inner.Start >= outer.Start && inner.Start + inner.Length <= outer.Start + outer.Length;

Steve French
Sep 8, 2003

dwazegek posted:

If you make the same off-by-one error on both sides of a comparison, is it still an error?

code:

bool isInRange = inner.Start >= outer.Start && inner.Start + inner.Length <= outer.Start + outer.Length;

Looks completely reasonable to me

Master_Odin
Apr 15, 2010

My spear never misses its mark...

ladies
code:
<!-- this one should have passed, but I think there is a Feature bug(not clearing the value) -->
...
<ExpectedResults
    <ExpectedException>java.lang.AssertionError</ExpectedException
</ExpectedResults>
No bug report for this that I could find. :psyduck:

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

Steve French posted:

Looks completely reasonable to me

Yeah, I should've provided more context.

There were a few legitimate off-by-one errors in related code where the (inclusive) upper bounds of the range was repeatedly calculated by doing start+length. I'm pretty sure the same buggy code was copy/pasted when writing this code, but because it's balanced on both sides of the comparison, it works.

1337JiveTurkey
Feb 17, 2005

I have no idea how the ranges are being used but for something like addressing ranges in an array wouldn't inner.Start + inner.Length overflow even though inner.Start + inner.Length - 1 could still be valid?

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
C# code:
public static DataTable BuildCustomerCombine(string sSalesRep, DateTime DelDateFrom, DateTime DelDateTo)
{...}
Hungarian notation (C#), improper parameter casing, terrible method name. Maybe more?

Steve French
Sep 8, 2003

1337JiveTurkey posted:

I have no idea how the ranges are being used but for something like addressing ranges in an array wouldn't inner.Start + inner.Length overflow even though inner.Start + inner.Length - 1 could still be valid?

Not clear if Start is a pointer or just an index. I read it as an index, in which case there is no problem. If it is a pointer, then, well, we have already had that long conversation.

Zamujasa
Oct 27, 2010



Bread Liar

PrBacterio posted:

That's actually the worst part about XML, yes, but I'd argue that it's a flaw of XML itself. I've seen this happen way too many times, with the people doing it refusing to back down even when called out on it -- "what? you're writing your own XML parser? have fun implementing all the details of that convoluted several-hundred-pages standards document - oh, you're not? well then it's not really XML, is it? -- 'stop bothering me, sperg, it too is XML! it uses angle brackets, see! just because I don't follow the standard doesn't mean it isn't XML, anything that uses angle brackets is XML and if you disagree you're a sperg, you sperg!!!'".

EDIT: What really bothers me about this is that in all of these cases, the people involved would have been better served to just use a simple ini-file style text file to store their key-value pairs or, if they just HAD to use XML for whatever reason, to just pick any of the vast number of existing XML libraries out there and use that but no, they just had to go and write their own (typically regexp-based) angle-bracket parser and call that bit of cargo cult programming "XML."

The best part is that one of the services we work with uses pseudo-XML, while also reserving 0a and 0d as the start and end characters of a packet.

:suicide:

NFX
Jun 2, 2008

Fun Shoe
We have an XML-like format in one of our products. It has to support boolean expressions, and we leave < and > unquoted. It works fine with out custom-built parser (partly because there's only a small number of valid tag names).

I'm fairly certain our philosophy is "if it ain't too broken, don't fix it."

dwazegek
Feb 11, 2005

WE CAN USE THIS :byodood:

1337JiveTurkey posted:

I have no idea how the ranges are being used but for something like addressing ranges in an array wouldn't inner.Start + inner.Length overflow even though inner.Start + inner.Length - 1 could still be valid?

I can't give any specifics, but there's no danger of overflowing. Both numbers are 32 bit integers, are always positive, and the maximum upper bound is never going to be more than 10 million.

shrughes
Oct 11, 2008

(call/cc call/cc)
One time I hand-parsed XML in LabVIEW.

HFX
Nov 29, 2004

Knyteguy posted:

C# code:
public static DataTable BuildCustomerCombine(string sSalesRep, DateTime DelDateFrom, DateTime DelDateTo)
{...}
Hungarian notation (C#), improper parameter casing, terrible method name. Maybe more?

It isn't as if C# doesn't encourage some Hungarian notation with its IAmAnInterface and TisType. It could be easy for a WinAPI programmer to slip into that habit. However, the rest of that is spot on.

HFX fucked around with this message at 19:22 on Sep 4, 2014

canis minor
May 4, 2011

Zamujasa posted:

The best part is that one of the services we work with uses pseudo-XML, while also reserving 0a and 0d as the start and end characters of a packet.

:suicide:

As far as XML horrors go, the biggest one I've had to deal with was document as:

code:
<SomethingSomething>
   &gt;SomethingElse&lt;
      &gt;SomethingElseElse&lt;
         [insert another entire XML document here, entity encoded, because why not]
      &gt;/SomethingElseElse&lt;
   &gt;/SomethingElse&lt;      
</SomethingSomething>
The details are hazy and I don't really remember why it was done this way, but yup, the entire content of the one node was entity encoded XML document, which had to be parsed.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

eithedog posted:

As far as XML horrors go, the biggest one I've had to deal with was document as:

code:

<SomethingSomething>
   >SomethingElse<
      >SomethingElseElse<
         [insert another entire XML document here, entity encoded, because why not]
      >/SomethingElseElse<
   >/SomethingElse<      
</SomethingSomething>

The details are hazy and I don't really remember why it was done this way, but yup, the entire content of the one node was entity encoded XML document, which had to be parsed.

Well, you need XML Professional Edition to get CDATA support.

Sedro
Dec 31, 2008

eithedog posted:

The details are hazy and I don't really remember why it was done this way, but yup, the entire content of the one node was entity encoded XML document, which had to be parsed.
That's what they meant by eXtensible, right?

ShadowHawk
Jun 25, 2000

CERTIFIED PRE OWNED TESLA OWNER

eithedog posted:

The OCD in me is sad that it's not buzziness
Mmm, you're right. I'll have to setup Perforce and roll out an update.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
Is it a horror that I now read "#region ..." as "hashtag region"?

Deus Rex
Mar 5, 2005

eithedog posted:

As far as XML horrors go, the biggest one I've had to deal with was document as:

code:
<SomethingSomething>
   &gt;SomethingElse&lt;
      &gt;SomethingElseElse&lt;
         [insert another entire XML document here, entity encoded, because why not]
      &gt;/SomethingElseElse&lt;
   &gt;/SomethingElse&lt;      
</SomethingSomething>
The details are hazy and I don't really remember why it was done this way, but yup, the entire content of the one node was entity encoded XML document, which had to be parsed.

Not to mention the &lt; and &gt; were flipped.

canis minor
May 4, 2011

Deus Rex posted:

Not to mention the &lt; and &gt; were flipped.

Ups, my mistake - the &gt; and &lt; were in correct places.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Knyteguy posted:

Kind of the wrong thread I know but what does a SOAP header actually provide? I always find it an annoyance, and I fail to see one useful thing it does that standard XML doesn't. I don't work with XML very often though so I don't have more than a glancing knowledge of pretty much what it looks like and a little bit of WPF stuff.

The basic idea is your SOAP WSDL can be consumed by some client and then it automatically knows how to use your API (what calls you can make, what arguments they accept, and what they return). This allows you to define the API once and then subsequently use it in any language (that has a way to consume the WSDL).

edit: Missed Snapchat A Titty's reply, whoops!

Nickopops
Jan 8, 2006
You must be this funky to ride.
.

Nickopops fucked around with this message at 09:28 on Nov 1, 2019

Soricidus
Oct 21, 2010
freedom-hating statist shill

Nickopops posted:

Also teaching first year university students Python is fun. Comments are denoted by a hashtag!
rm -rf / #yolo

Adbot
ADBOT LOVES YOU

Vanadium
Jan 8, 2005

Rust attributes #[look_like_this] and I've unsuccessfully attempted to make them drop the brackets and make attributes postfix. :(

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