Monthly Archives: June 2013

Beginning SQL Server Tips

Use datetime2 instead of datetime or smalldatetime.  Datetime2 is ANSI standard whereas the other two a SQL Server specific.  Smalldatetime is more space efficient but 4 bytes vs 8 bytes is almost never going to be important.

http://technet.microsoft.com/en-us/library/bb677335.aspx

Chayote

image

Looks like the chayote is doing ok but not nearly as well as you would expect for its age.

Minimum XML Subset

XML is a wonderful thing.  It has helped us, to a large extent, to move from an enterprise full of siloed systems to easy data sharing (albeit with much greater complexity, interdependence, and fragility).  For years XML was taken for granted but then JSON came along.  JSON is even more compact than XML but I believe it really caught on because it is simpler and less formal.  JSON has gotten a lot of hype over the last few years.

XML is too complicated, should we us JSON?

Though JSON is very useful for interacting with JavaScript, I would not use it for generic data interchange.  Why?  Though JSON adoption is widespread it is not as available in programming environments which often end up lagging the latest technologies by many years.  And why should they when XML works just as well?  You may develop something in JSON and find that it works well with all the systems you need to integrate with but couple of years later and you find something else that it doesn’t work with or requires a 3rd party library to be downloaded.  The whole reason you are providing data in the first place is SOA, and that means that you are trying to accommodate unexpected future needs.  XML seems to be supported in a superset of situations where JSON is supported.  By using JSON you are reducing the number of options available in the future. In fact, since JavaScript can work just fine with XML (jQuery.parseXML), I would use XML even for JavaScript integration.

If you are tempted to use JSON because it is smaller, don’t give in.  Use compression instead, it works much better most of the time.

What to do about XML

Even in the XML world, I would recommend some restrictions.  Programmers don’t usually use XML and XSLT as frequently as their main programming languages so there is a major cost to using any XML at all.  Why add to the cost by using more XML features than we absolutely have to?

If you are generating a text file for someone else to consume, use XML, but use only the Minimum XML features necessary.

  1. Omit the XML declaration: <?xml version=”1.0″ encoding=”UTF-8″ ?> unless you need it for using non-ANSI characters.
  2. Do not use namespaces
  3. Do not use entity references (besides &amp; &lt; and &gt;)
  4. Do not use element attributes
  5. Do not mix tags and text in the same element
  6. Do not use CDATA

XML itself came from a much more complicated standard called SGML.  XML is still much more complicated than it needs to be or we wouldn’t have seen the JSON backlash.

I was very late to this discussion, a formal specification was written up more than a decade ago.  But most important things need to be repeated.