<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Stefan Tilkov's Random Stuff]]></title>
  <link href="http://www.innoq.com/blog/st/atom.xml" rel="self"/>
  <link href="http://www.innoq.com/blog/st/"/>
  <updated>2012-02-07T13:52:54+01:00</updated>
  <id>http://www.innoq.com/blog/st/</id>
  <author>
    <name><![CDATA[Stefan Tilkov]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Blog update]]></title>
    <link href="http://www.innoq.com/blog/st/2012/02/blog-update/"/>
    <updated>2012-02-05T20:41:00+01:00</updated>
    <id>http://www.innoq.com/blog/st/2012/02/blog-update</id>
    <content type="html"><![CDATA[<p>I took the opportunity of a 10-hour flight to finally re-import all of
my blog&#8217;s old entries into Octopress, fiddling around with a
semi-automated process of Ruby and shell scripts and some creative
Emacs macros (check out <a href='http://www.innoq.com/blog/st/blog/st/archives/'>the archives</a>
if you care, even though I have no idea why you would). So if this
worked, all of the old stuff should be preserved, even though most of
it now only has historic value (and prevents Google searches to hit a
404). I&#8217;ve also taken the risk of moving the whole stuff back <a
href='http://www.innoq.com/blog/st/blog/st/'>to its old location</a>, and will redirect the
temporary one back once I&#8217;m sure everything works. One less excuse to
not take up blogging again &#8230;</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[XPath and XML]]></title>
    <link href="http://www.innoq.com/blog/st/2012/01/xpath/"/>
    <updated>2012-01-14T17:45:00+01:00</updated>
    <id>http://www.innoq.com/blog/st/2012/01/xpath</id>
    <content type="html"><![CDATA[<p>Aristotle Pagaltzis has written <a
href='http://plasmasturm.org/log/xpath101/'>a very nice and concise XPath intro</a>.
 Of all the various standards in the XML ecosystem, I
like XPath best, most of all because it enables interaction with an
XML document or message in a way that matches <a
href='http://en.wikipedia.org/wiki/Robustness_principle'>Postel&#8217;s law</a>: It&#8217;s a great way to implement code that doesn&#8217;t break each
time a minor change is made to an XML format. In fact I&#8217;d say it&#8217;s one
the few very good reasons to stick with XML instead of adopting JSON
&#8211; even though there are things like <a
href='http://goessner.net/articles/JsonPath/'>JSONPath</a>, they don&#8217;t
have the tool support and standardization you get from XPath.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Media Types in RESTful HTTP]]></title>
    <link href="http://www.innoq.com/blog/st/2011/12/media-types/"/>
    <updated>2011-12-03T11:15:00+01:00</updated>
    <id>http://www.innoq.com/blog/st/2011/12/media-types</id>
    <content type="html"><![CDATA[<p>A topic that comes up again and again in discussions about RESTful
design is what kinds of media type to use. I&#8217;ve changed my mind about
this a few times, often enough so that I believe it makes sense to write
a bit about my current thinking on this. (A &#8220;media type&#8221;, should you
happen to wonder what I&#8217;m talking about, is a specific format with a
well-defined name, in this context represented in the form of a media
type identifier such as <code>application/xml</code> or <code>text/html</code> or
<code>application/json</code>. [That&#8217;s not 100% correct, but that doesn&#8217;t really
matter here.] A &#8220;hypermedia format&#8221; is one that includes links or other
hypermedia controls.)</p>

<p>There are a number of different ways to deal with media types when
designing a RESTful HTTP system. One school of thought advises to
stick with hypermedia formats/media types that are well-defined and
widely understood, such as HTML or Atom. In other words: Whatever it
is you&#8217;re trying to send around as part of an HTTP message, use an
existing format, such as HTML, the main reason being that there are
many processors that are able to understand it. Use the appropriate
MIME identifier (such as <code>text/html</code>) in Content-type headers. One can
make a strong case for this option: Hypermedia formats are
hard to design, so you should avoid inventing your own.</p>

<p>But let&#8217;s assume you&#8217;ve decided to define your own hypermedia format,
<a href='http://www.amundsen.com/blog/archives/1101'>mike
amundsen-style</a>, whether by designing a completely new XML
vocabulary, your own JSON structure, or some other approach: What MIME
type do you use?</p>

<p>You can send content labeling it with the generic identifier, say
<code>application/xml</code>. In this case, the MIME identifier will signal the
technical format being used, while the semantics are only known to
clients who either have some out-of-band knowledge or interpret the
content itself. The rationale for this approach is that unless your
home-grown hypermedia format is likely to be widely adopted, you&#8217;d
better stick with a media type that is well-known, even though it
doesn&#8217;t convey specific semantics. <a href='http://duncan-cragg.org/blog/post/minting-media-types-usually-less-restful-using-raw/'>Duncan Cragg wrote a nice post</a> on this a while back.</p>

<p>The second option is to invent your own MIME type, say
<code>application/vnd.mycompany-myformat</code>, the argument being that you need
to convey the semantics of the content to ensure a client, server or
intermediary can actually know whether it&#8217;s able to process it.</p>

<p>This begs the question of how many different MIME types you&#8217;ll end up
with. Instead of creating a new identifier for each type of content,
(e.g. a customer, a list of customers, a list of orders), I&#8217;ve found
that a good approach is to think of a specific context &#8211; a <em>domain</em>, if
you prefer &#8211; that your format covers. I like the similarity of this
approach to other hypermedia formats, e.g. HTML or Atom/AtomPub, where
you actually end up describing something that applies to a set of
collaborating participants, instead of some server-side interface. In
my favorite example domain (order processing), you might end up with a
MIME type of <code>application/vnd.mycompany-ordermanagement</code>, relate this
to a particular XML namespace and define a few different XML root
elements (order, order confirmation, cancellation, etc.). The
assumption would be that processors can be reasonably expected to able
to understand all of the elements in this context, not just one of
them. (Of course the same reasoning applies when using JSON or
something else, minus the namespace benefits/troubles, depending on
your view of XML.)</p>

<p>One final approach that I find very interesting was mentioned by <a
href='http://algermissen.blogspot.com/'>Jan Algermissen</a> a while
ago: If your format is based on an existing one, e.g. HTML or XML,
your server can actually send the same content with different MIME
types, depending on the client&#8217;s capabilities. A client that only
included <code>application/json</code> in its Accept header would then get the
content labeled <code>application/json</code>, while one that includes the
specific MIME type <code>application/vnd.whatever</code> would get the same
content with this label applied.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[A Fresh Start ... Again]]></title>
    <link href="http://www.innoq.com/blog/st/2011/12/a-fresh-start/"/>
    <updated>2011-12-02T18:54:00+01:00</updated>
    <id>http://www.innoq.com/blog/st/2011/12/a-fresh-start</id>
    <content type="html"><![CDATA[<p>Google Reader&#8217;s extremely weird behavior after a first attempt to move
<a href='http://www.innoq.com/blog/st/'>my blog</a> to a new location has made me try
yet another different blog setup. This time, there should be
nothing at all left from the old installation, no redirects, different
URIs for everything, a new blog system &#8211; clearly, there&#8217;s no way for
Google Reader to mess things up this time. Let that be the last thing
said about this mess; even though it&#8217;s very sad to see all of those
blog followers go who only occasionally drop by whenever something new
appears in their Google Reader subscription, many of them may not have
been following anymore, anyway. Who knows. It&#8217;s been a long time since
I spent some serious time blogging.</p>

<p>Which doesn&#8217;t mean one can&#8217;t restart, right? We&#8217;ll see. For now, this
is the one and only blog I&#8217;ll maintain. It has zero moving parts,
i.e. it&#8217;s a static site, (currently) generated using
<a href="http://octopress.org/">Octopress</a>. If everything works as expected,
you&#8217;ll be able to subcribe to the
<a href="http://www.innoq.com/blog/stilkov/atom.xml">an Atom</a> feed that should
actually be working for a change.</p>

<p>I&#8217;m somewhat undecided with regards to comments and the Twitter
integration (both in the sidebar as well as in the bottom of each
post). I&#8217;ve toyed with the idea of doing away with comments
altogether, but I have to say that <a href="http://disqus.com/">Disqus</a> seems
quite smart.</p>
]]></content>
  </entry>
  
</feed>

