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

  <title><![CDATA[Sergey Shishkin]]></title>
  <link href="http://shishkin.org/atom.xml" rel="self"/>
  <link href="http://shishkin.org/"/>
  <updated>2013-11-14T17:18:12+01:00</updated>
  <id>http://shishkin.org/</id>
  <author>
    <name><![CDATA[Sergey Shishkin]]></name>
    <email><![CDATA[sergey@shishkin.org]]></email>
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Exploring Lean Architecture]]></title>
    <link href="http://shishkin.org/blog/exploring-lean-architecture/"/>
    <updated>2013-03-24T00:00:00+01:00</updated>
    <id>http://shishkin.org/blog/exploring-lean-architecture</id>
    <content type="html"><![CDATA[<p><span class='pullquote-right' data-pullquote='Can architecture help prevent waste without being wasteful itself?'> The topic of software architecture is very controversial in the agile community. Opinions vary from &ldquo;architecture emerges by itself&rdquo; to &ldquo;spend <em>Sprint-Zero</em> on architecture and required infrastructure&rdquo;. Both these extremes are far from being lean, because lean in essence is about reducing waste and maximizing long-term value. Sprint-Zero architecture is BDUF – big design upfront – and is wasteful because its value won&rsquo;t get fully realized until the very last part of implementation is done. Emergent architecture (being dictated by the underlying implementation) is wasteful because it constantly causes rework and refactoring at the architectural level is never easy. It also wastes informational context: strategic macro-level decisions (and thus their justifications) are buried in the implementation details where they are indistinguishable from tactical micro-level decisions.</p>

<p>But what is in between those extremes? Can architecture help prevent waste without being wasteful itself? What is lean architecture? I tried to find it out experimentally.</span></p>

<h3>Architectural Kata</h3>

<p>First time I&rsquo;ve learnt about <a href="http://blogs.tedneward.com">Ted Neward</a>&rsquo;s <a href="http://archkatas.herokuapp.com">architectural katas</a> from <a href="http://www.squeakyvessel.com">Benjamin Reitzammer</a> at <a href="http://www.socrates-conference.de">SoCraTes Conference</a>. Since then I&rsquo;ve facilitated several architectural katas myself at different community events. My style of facilitating can be described as exploratory: I neither prescribe any particular method to solve the kata nor do I require any particular presentation format – words or pictures or a mixture. The only constraints are:</p>

<ul>
<li>30 minutes for preparation, 5 minutes for presentation;</li>
<li>work in a group of people you don&rsquo;t know well (otherwise I&rsquo;d give 20 minutes for preparation);</li>
<li><strong>communicate</strong> and <strong>justify</strong> macro-level decisions (does it count for the definition of the architecture in lean context?);</li>
<li>state assumptions explicitly.</li>
</ul>


<p>I also give some hints:</p>

<ul>
<li>to focus on getting quick feedback on technical feasibility and costs;</li>
<li>don&rsquo;t spend too much time on modeling the problem domain as it can be done later on the micro-level;</li>
<li>I also say something like &ldquo;I want to see data flowing&rdquo; (more on that later).</li>
</ul>


<h3>Lessons Learned</h3>

<p>Most participants get frustrated after their first kata because of how little they&rsquo;ve actually scratched on the solution domain surface. Many of them complained about the time box being too short. I always replied that if you have no plan, then the quicker you realize it the better, but if you have one and it requires more time, try to make it leaner next time. I used frustration on purpose as motivating factor and to raise the awareness that architecture requires deliberate practice too.</p>

<p>After each kata I also saw good patterns in solutions people propose:</p>

<ul>
<li>split the system based on domain functionality;</li>
<li>identify data flows between sub-systems;</li>
<li>identify different actors and sub-systems they communicate with.</li>
</ul>


<p>Many participants demanded to see <em>my</em> solution, which I shamelessly stitched together from the patterns mentioned above. That approach was every time well received. I was hesitant though because it was just one way and I was more interested in letting people explore new ideas.</p>

<p>Each time a long and very constructive discussion about architecture in general and architecture in agile followed the kata. And I always notices that participants learned about architecture a lot and so did I. Common feedback was also to have a chance to immediately apply acquired knowledge to a new kata.</p>

<h3>Rinse and Repeat – Architecture Retreat</h3>

<p>Since the time frame of a conference session or an evening meet-up couldn&rsquo;t squeeze several katas I decided to try out a new format – <em>Architecture Retreat</em> (inspired by the <a href="http://coderetreat.org">Code Retreat</a>). And just yesterday at <a href="http://spartakiade.org">Spartakiade 2013</a> in Berlin I&rsquo;ve got a chance to facilitate the first mini Architecture Retreat. Due to time limitations (again) it consisted of just two katas. We had 3 groups and shuffled them between the katas. There were two different katas: the first one was a simplification of <a href="http://archkatas.herokuapp.com/kata.html?kata=WheresFluffy.json">Where&rsquo;s Fluffy</a> (without rewards) and the second one was a custom kata – a community platform with local sub-groups, mailing lists and events (<a href="http://softwerkskammer.de">German software craftsmanship community</a> is <a href="https://github.com/softwerkskammer">building one</a> now).</p>

<p>Surprisingly enough the first kata went better: groups identified actors, sub-systems and interactions. The second one didn&rsquo;t go beyond requirements engineering and problem domain modeling. The feedback was that the second problem was broader and less known (too few Spartakiade participants were members of the German software craftsmanship community unfortunately). It was also proposed to try the same kata over and over again (although with additional requirements each time) to avoid the initial problem domain learning curve. I&rsquo;m still convinced that soliciting requirements from the customer on-site is essential part of an architectural kata though. Anyway it might be a Legacy Architecture Retreat (why not?): in a short time-box describe and refactor an existing architecture in order to embrace a new requirement. Sounds good to me.</p>

<h3>What&rsquo;s Next?</h3>

<p>How to learn just enough problem domain and incorporate requirements into the architecture one by one in a lean way will be the topic of my next blog post. Yesterday I tried one approach to the second kata myself which went quite well, though I need some more time to generalize and document the method. In a nutshell I&rsquo;ve applied TDD on the architectural macro-level using use-cases as tests.</p>

<p>The next Architecture Retreat will be held at the <a href="http://softwerkskammer.de/wiki/SoftwerkskammerDUS">Düsseldorf software craftsmanship community</a> on 11th May. Stay tuned.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Designing Web API]]></title>
    <link href="http://shishkin.org/blog/designing-web-api/"/>
    <updated>2013-01-26T00:00:00+01:00</updated>
    <id>http://shishkin.org/blog/designing-web-api</id>
    <content type="html"><![CDATA[<p>Earlier this week I gave a <a href="http://www.sigs-datacom.de/oop2013/konferenz/sessiondetails.html?tx_mwconferences_pi1%5BshowUid%5D=999&amp;tx_mwconferences_pi1%5Banchor%5D=%23Di71&amp;tx_mwconferences_pi1%5Bs%5D=0">workshop on Web API Design</a> at <a href="http://www.sigs-datacom.de/oop2013/konferenz/konferenzprogramm.html">OOP 2013</a> in Munich, which I want to summarize in a blog post.</p>

<p>With only a flip chart and markers I started designing from scratch a web API with heavy use of hypermedia for an imaginary “groups and events” website a la meetup.com. The following features have been covered iteratively, one by one, showing the benefits of the hypermedia approach:</p>

<ul>
<li>events – open  and link together the core data of the site;</li>
<li>personalization – user-specific resources like “my events”;</li>
<li>search – allow for parameterized querying;</li>
<li>groups and topics – simply more linked data mainly to illustrate addition of core features at a later stage;</li>
<li><a href="http://en.wikipedia.org/wiki/RSVP_(invitations)">RSVP</a> – doing updates driven by hypermedia.</li>
</ul>


<h3>Start</h3>

<p>I asked the audience which format they prefer for the representations and they voted for JSON although I mentioned that HTML would make many further steps easier. Anyways, format is in my opinion subject to <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html">content negotiation</a> and a new one can always be added later.</p>

<p>Usually the next step would be to come up with a URI tree of resources, which will form the API. This wasn&rsquo;t what I did though. Instead I suggested to decide on a hypermedia-driven way the clients will discover available resources. With absence of hypermedia RESTful APIs rely on developer documentation for that purpose. A much better approach to me is a single well-known resource, serving as an entry point into the API and containing only the valid of the potential next interaction steps. The <a href="http://tools.ietf.org/html/draft-nottingham-json-home">Home Document draft</a> for example specifies how such resource might look like in JSON.</p>

<h3>Linked Data</h3>

<p>Having defined the entry point into the API, we can move to modeling the core domain resources. Since we solely rely on hypermedia for discovering resources starting from a single well-known entry point, it is logical to visualize the design process with a directed graph, where nodes represent resources (or states of application interaction) and edges represent hypermedia controls leading from one resource to another.</p>

<p><a href="http://shishkin.org/images/2013-01-24-events.jpg"><img class="right" src="http://shishkin.org/images/2013-01-24-events.jpg" width="384" height="400" title="Resources Overview" ></a>
An example of such a graph is my poor flip chart drawing on the right. Here we start with the <code>Home</code> resource and by means of a hypermedia link known as <code>upcoming-events</code> navigate to a resource of type <code>Events</code> representing all the upcoming events on the site. <em>Nodes on the graph really represent whole classes of resources or resource types – showing individual resources on a graph would hinder the overview.</em></p>

<p>The <code>upcoming-events</code> hypermedia control (a green arrow) is simply a link in a <a href="http://tools.ietf.org/html/draft-nottingham-json-home">JSON Home Document</a>, but the <code>Events</code> representation has a collection semantics, containing individual events, which are separate resources on their own right. To avoid reinventing the wheel, we&rsquo;ll use the <a href="http://amundsen.com/media-types/collection/">Collection+JSON</a> media type to represent event collections. Collection+JSON resources can reference other resources via links, which comes in handy e.g. for pagination with <a href="http://www.iana.org/assignments/link-relations/link-relations.xml">link relation types</a> <code>next</code> and <code>prev</code>.</p>

<p>There is a more ubiquitous representation of event collections though, which is <a href="http://tools.ietf.org/html/rfc2445">iCalendar</a>. iCalendar format automatically opens our data to all sort of calendar applications like Outlook, iCal and Google Calendar. It is a low hanging fruit in terms of interoperability, which is the primary aim for open data and APIs. Solutions like iCalendar or <a href="https://tools.ietf.org/html/rfc4287">Atom</a> feeds should probably be considered as Lo-Fi API alternatives at the early stage of API development.</p>

<p>In REST terms iCalendar and JSON are just different representations of the same resource and thus should share the same URI. The client then will have to ask for the desired representation with the <code>Accept</code> request header. This is unpractical though, since the iCalendar feed will be requested by clients like browsers and calendar applications, which won&rsquo;t bother requesting the special iCalendar media type. A much more interoperable option would be to provide a link with the relation type <code>alternate</code> from the JSON representation (or add it directly to the <code>Home</code>).</p>

<h3>Personalization</h3>

<p>From the hypermedia perspective a resource like “my events” is just another resource, linked from somewhere and linking to somewhere else. The trick is that it can only be accessed with a valid authentication. The drawing above shows two ways of of discovering personalized resources via hypermedia: The first one is the link <code>my-upcoming-events</code>, which — when activated — responds with a standard HTTP authentication challenge (depicted with the red padlock). Another option is a loopback link (red arrow <code>Auth</code>) from <code>Home</code> to itself, meaning that the client receives upon authentication a personalized representation of the <code>Home</code> resource with a (previously not present) <code>my-upcoming-events</code> link.</p>

<h3>Querying</h3>

<p>Event search results are basically just a collection of events, for which we already have a resource type <code>Events</code>. We will reuse the same linking mechanisms to expose the event search results via the <code>search-events</code> link. Search however requires some user input to generate a representation of search results. The <a href="http://tools.ietf.org/html/rfc6570">URI Template</a> specifies a way of formatting parameterized URIs. There are already libraries available for expanding URI templates, so the clients shall have no problems consuming those.</p>

<h3>More Links</h3>

<p>We can now search for and navigate upcoming events, which are already valuable features. Even without topics and groups the API is a viable product worth exposing and consuming. Adding topics and groups to the mix at this stage is neither late nor difficult. We add <code>all-topics</code> link from <code>Home</code> to the <code>Topics</code> resource type. It might as well be <code>popular-topics</code> or any other reasonable default collection semantic, or even several of them to choose from. The <code>Topics</code> collection contains individual topics and may be searched or filtered using a parameterized link. A <code>Topic</code> resource references a collection of events and a collection of groups, both filtered by the topic. <code>Groups</code> and <code>Group</code> resources follow the same pattern of collections and links.</p>

<p>Collection+JSON provides collection semantics and linking capabilities. It is however not the only one option. The <a href="http://stateless.co/hal_specification.html">Hypertext Application Language</a> (HAL) allows to embed multiple resources in a single JSON (or XML) representation and to link to other resources. The <a href="http://tools.ietf.org/html/rfc5988">Web Linking</a> describes a format-neutral way of putting links in a special <code>Link</code> HTTP response header.</p>

<h3>Updates</h3>

<p>Until now we&rsquo;ve dealt with safe read-only HTTP GET requests, but rsvp&#8217;ing an event is an update and should be modeled with an appropriate HTTP verb.</p>

<p><a href="http://shishkin.org/images/2013-01-24-rsvp.jpg"><img class="left" src="http://shishkin.org/images/2013-01-24-rsvp.jpg" width="380" height="216" title="RSVP Workflow" ></a>
In case of a simple yes/no answer it is sufficient to mark the respective <code>accept</code> or <code>decline</code> link (see the drawing on the left) with the <code>"method": "POST"</code> attribute. The client will <code>POST</code> the request to the specified URI and the server will redirect the client back to the <code>Event</code> resource. But what if we want to receive a short text note from the user along with the answer?</p>

<p>We could also model the <code>RSVP</code> resource as a Collection+JSON type with a <a href="http://amundsen.com/media-types/collection/examples/#ex-template">built-in item template</a> and defined semantics for adding new items. That way the client navigates to the <code>RSVP</code> collection from the corresponding event, then it finds the item template, fills the template out (adding the attendance status and the optional text note), POSTs the filled-out template to the specified URI and gets redirected to the updated <code>RSVP</code> collection.</p>

<p>Another option would be to add the notion of a POST payload template to other types of links (e.g. HAL links). The benefit of explicit <code>accept</code> and <code>decline</code> links — compared to a generic collection update — is that the server only exposes the valid options in the current context: the user can&rsquo;t accept an event twice.</p>

<h3>Bottom Line</h3>

<p>This approach to designing Web APIs is very simple and boils down to defining resources  and deciding which formats suit representations better and which hypermedia controls to  use to navigate from one resource to another. In this example we used the following hypermedia controls: collections, simple links, authenticated links, query links and update links. There are already standards for implementing some these basic building blocks and more standards will emerge. Focusing on the semantics of hypermedia controls during design will help to evolve and tweak the implementation down the road.</p>

<p>Let&rsquo;s consider the amount of out-of-band information, which client developers will have to look up in the API documentation in order to make API calls:</p>

<ul>
<li>The single URI of the API entry point (the Home Document);</li>
<li>Link relation types used in the API (e.g. <code>my-upcoming-events</code> and <code>accept</code>) and their meaning;</li>
<li>Formats of the resource representations (e.g. <code>Events</code>, <code>Event</code>, <code>Group</code> etc.);</li>
<li>URI Template parameters and their meaning (e.g. <code>searchTerms</code> as the search query input);</li>
<li>Parameters used in the item templates for update requests and their meaning (e.g. <code>note</code> for the text note of an RSVP answer).</li>
</ul>


<p>All this information is domain-specific and is basically what differentiates a social events API from an accounting API. All the technical details are encapsulated into generic media types (e.g. Collection+JSON and HAL) and is ideally handled by generic hypermedia client libraries.</p>

<h3>References</h3>

<ul>
<li><a href="http://tools.ietf.org/html/draft-nottingham-json-home">Home Document draft</a></li>
<li><a href="http://amundsen.com/media-types/collection/">Collection+JSON</a></li>
<li><a href="http://www.iana.org/assignments/link-relations/link-relations.xml">Link relation types</a></li>
<li><a href="http://tools.ietf.org/html/rfc2445">iCalendar</a></li>
<li><a href="https://tools.ietf.org/html/rfc4287">Atom</a></li>
<li><a href="http://tools.ietf.org/html/rfc6570">URI Template</a></li>
<li><a href="http://stateless.co/hal_specification.html">Hypertext Application Language</a></li>
<li><a href="http://tools.ietf.org/html/rfc5988">Web Linking</a></li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Hypermedia DNA]]></title>
    <link href="http://shishkin.org/blog/hypermedia-dna/"/>
    <updated>2013-01-19T00:00:00+01:00</updated>
    <id>http://shishkin.org/blog/hypermedia-dna</id>
    <content type="html"><![CDATA[<p>I played with this little idea for quite some time and finally decided to blog about it. As hypermedia getting traction now (e.g. <a href="http://developer.github.com/v3/#hypermedia">GitHub API introduced some hypermedia</a>) more people think about standardized ways of doing it. Unfortunately the de-facto standard representational format for machine-to-machine communication on the Web — JSON — doesn&rsquo;t provide any of the <a href="http://amundsen.com/hypermedia/hfactor/">hypermedia factors</a> out of the box.</p>

<p>The most notable standardization effort in this area — <a href="http://tools.ietf.org/html/draft-kelly-json-hal">Hypertext Application Language</a> — takes in my opinion the all-or-nothing limiting and heavyweight approach: your implementation either complies with HAL or it doesn&rsquo;t. So implementers who don&rsquo;t want 100% HAL just roll out their own completely unique media types with no interoperability at all. Can we achieve interoperability and embrace diversity at the same time? It turns out that we can.</p>

<h3>Evolutionary Lesson</h3>

<p><span class='pullquote-right' data-pullquote='What if hypermedia types would be defined as combinations of standard building blocks?'> Nature itself has solved the same problem quite elegantly: every living being carries sequence (the <a href="http://en.wikipedia.org/wiki/DNA">DNA</a>) of standardized parts encoding a unique combination of properties the living being will have. During replication two DNAs are combined to produce a new and unique one.</p>

<p>What if hypermedia types would be defined as combinations of standard building blocks? These small standardized building blocks — <em>hypermedia genes</em> — will describe how exactly that particular hypermedia factor is supported by an implementation. API designers won&rsquo;t have to decide whether the complete HAL specification meets their needs. An API designer might like HAL link objects, but dislike underscores in attribute names and not need resource embedding. No problem, just cherry-pick useful <em>genes</em> and replicate a new and interoperable hypermedia type. </span></p>

<h3>The Hypermedia Genome</h3>

<p>How can these hypermedia genes look like? Small hypermedia features in different flavors like a particular representation of links or ways of reporting errors can be defined, named and catalogued. Last year I started describing a set of such hypermedia controls for JSON named <a href="http://documentup.com/shishkin/json-hypcos">JSON Hypcos</a> (<em>hypco</em> is short for hypermedia control). The list is by no means complete, those are just some of the hypermedia controls I use in my work.</p>

<p><span class='pullquote-left' data-pullquote='focus on application semantics instead of the wire implementation of the interface'> Describing individual hypermedia controls instead of trapping them in all-or-nothing media types has many benefits. Like <a href="http://microformats.org/">microformats</a> applied to existing data, standardized hypermedia controls can describe existing API designs giving them standardized semantics.</p>

<p>Client developers can grok new APIs easier, if those APIs are defined out of well-known building blocks. Documenting APIs will also require much less effort, if hypermedia controls become commodity. Generic hypermedia client libraries can hide APIs&#8217; diverse flavors behind equivalent semantic of hypermedia controls, allowing client developers to focus on application semantics instead of the wire implementation of the interface. </span></p>

<h3>Discoverability</h3>

<p>The good thing about standardized media types is that we further have standardized means of advertising and discovering client and server capabilities in terms of media types. I talk about the <code>Accept</code> and <code>Content-Type</code> HTTP headers. If individual hypermedia genes become media type description units, we also need content negotiation on this finer-grained atomic level.</p>

<p>First of all, each hypermedia control flavor must be uniquely addressable. URI? Probably. Consider <code>urn:json-hypco:link-object</code> or even shorter <code>urn:hc:lo</code>. Remember that a complete media type will consist of a dozen or more of these. For efficiency multiple hypermedia genes can be combined like this: <code>urn:hc:lo+lr+sl+lh+tu</code> (<em>hypermedia chromosomes?</em>).</p>

<p>API&rsquo;s complete hypermedia DNA might be advertised by the server with an HTTP response header like <code>Content-Controls: urn:hc:lo+lr+sl+lh+tu urn:foo:bar ...</code>. Clients might also declare their level of hypermedia support: <code>Accept-Controls: urn:hc:lv+tu</code>.</p>

<h3>What Next?</h3>

<p>This blog post is my unofficial request for comments. It is my take at bringing interoperability into the emerging hypermedia API space while still embracing its diversity and evolution. I&rsquo;m more then excited to hear from anyone interested in the topic.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Lean Startup For Your Agile Toolbox]]></title>
    <link href="http://shishkin.org/blog/lean-startup-for-your-agile-toolbox/"/>
    <updated>2012-10-09T17:16:00+02:00</updated>
    <id>http://shishkin.org/blog/lean-startup-for-your-agile-toolbox</id>
    <content type="html"><![CDATA[<p><a href="http://www.goodreads.com/book/show/13078769-running-lean"><img class="right" src="http://photo.goodreads.com/books/1344712076l/13078769.jpg" title="Running Lean" ></a></p>

<p>I was at the local <a href="https://www.xing.com/events/22-agiler-stammtisch-dusseldorf-thema-open-space-software-development-ale-2012-1114192">agile meet-up</a> when the same old topic of Scrum dysfunctions and a lack of process guidance arose. In my opinion the ability to act in absence of process guidance is really a sign of a competent practitioner as opposed to a &ldquo;certified process follower&rdquo;. Without clear prescriptions the richness of one&rsquo;s own toolbox is essential. Recent study of the <a href="http://theleanstartup.com/principles">Lean Startup</a> methodology and especially the read of <a href="http://www.goodreads.com/book/show/13078769-running-lean">Running Lean</a> by Ash Maurya gave me some <em>more</em> ideas of what to do when the process of choice is silent.</p>

<h3>Missing User Roles</h3>

<p>&ldquo;As a [<em>role</em>] I want [<em>feature</em>] so that [<em>benefit</em>].&rdquo; The most important part of a user story is not the feature but rather the user role and the benefit he wants to achieve. It has been proven effective for ages in the agile world to put <a href="http://www.infoq.com/presentations/pragmatic-personas">personas</a> in the user stories, but <a href="http://steveblank.com/2012/03/29/nail-the-customer-development-manifesto/">customer development</a> makes it obligatory. You have to know your customer segments and their must-have problems in order to provide benefit to the user. If your user stories don&rsquo;t mention a particular customer group and a problem (which you&rsquo;ve validated qualitatively), chances are you&rsquo;re building some sort of waste. Note that &ldquo;working software&rdquo; and &ldquo;definition of done&rdquo; is all waste, if the problem it solves is not worth solving.</p>

<h3>Backlog Prioritization</h3>

<p><span class='pullquote-left' data-pullquote='building an experiment for quantitative verification of the riskiest hypothesis is clearly the most important thing right now'>
Juggling backlog priorities is often compared with art, politics, black magic, blind guesses, coin flipping – with anything but a scientific method. One scientific approach to prioritization would be to eliminate risks highest first and thus accelerate learning. After qualitative validation of the biggest assumptions it&rsquo;s time to verify them quantitatively. So building an experiment for quantitative verification of the riskiest hypothesis is clearly the most important thing right now. And if the simplest possible way to build that experiment is by giving a working software in the users&#8217; hands, great.
</span></p>

<p>When building the solution one increment at a time, constantly trace the features back to the customer segments and their problems. Is this feature a part of the minimal viable product for that particular segment? If not, chances are you&rsquo;re building something for a new customer segment which has to be validated and verified first.</p>

<p>The <a href="http://www.ashmaurya.com/2012/02/why-lean-canvas/">lean canvas</a> (and its ancestor, the <a href="http://www.businessmodelgeneration.com/canvas">business model canvas</a>, for that matter too) is a perfect tool to capture two important aspects of of a product idea: cost structure and revenue streams. A product idea can have multiple revenue streams, one for each customer segment. Analyzing which feature contributes to which revenue stream can make prioritization a lot easier.</p>

<h3>Acceptance Criteria</h3>

<p><span class='pullquote-right' data-pullquote='You&#8217;re done, when you&#8217;ve validated, verified or denied a hypothesis'>
This is the new definition of <em>DONE</em>: You&rsquo;re done, when you&rsquo;ve validated, verified or denied a hypothesis. The difference between validation and verification being that you validate qualitatively and verify quantitatively. Registering either a positive or a negative signal when talking to people is qualitative validation. Turning 10% newsletter recipients into paying customers is quantitative verification.</p>

<p>Look at the <a href="http://lean.st/principles/build-measure-learn">build-measure-learn</a> principle. When defining the acceptance criteria for a user story, think about learning first. What hypothesis are you trying to verify and what measurable metric to use for it? If nothing comes to mind, chances are you&rsquo;re not developing, because development implies learning.
</span></p>

<h3>Systems Thinking (In Closing)</h3>

<p>It&rsquo;s really about the holistic view of the value chain. You can pretend to be doing Scrum or some other agile method just in the IT, but local optimization will inevitably bite you in the ass. Customer development techniques are a powerful tool to help a product owner with his homework – backlog grooming and prioritization. Keeping a constant eye on the aspects of the <a href="http://www.ashmaurya.com/2012/02/why-lean-canvas/">lean canvas</a> helps making uncomfortable decisions with a reason and confidence.</p>

<p>[Update 11th Oct 2012]: Improved wording used for the user story.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Separation of Data and Actions in Hypermedia APIs]]></title>
    <link href="http://shishkin.org/blog/separation-of-data-and-actions-in-hypermedia-apis/"/>
    <updated>2012-08-06T18:04:00+02:00</updated>
    <id>http://shishkin.org/blog/separation-of-data-and-actions-in-hypermedia-apis</id>
    <content type="html"><![CDATA[<p>Last time I <a href="http://shishkin.org/blog/data-actions-impedance-mismatch">wrote</a> about the <a href="http://martinfowler.com/bliki/AnemicDomainModel.html">Anemic Domain Model</a> anti-pattern often observed in RESTful Web APIs. The design smell manifests itself in the data resources exposing CRUD behavior via POST, PUT and DELETE methods. This time I won&rsquo;t go again through all the complications resulting from such design, but rather just start describing a possible solution.</p>

<p>As a long-time proponent of <a href="http://en.wikipedia.org/wiki/Domain-driven_design">Domain-Driven Design</a> and a follower of its recent advancement – <a href="http://martinfowler.com/bliki/CQRS.html">Command-Query Responsibility Segregation</a> – the solution to apply CQRS to cure anemic domain model seemed quite natural to me (and it still seems so). But how exactly CQRS helps designing hypermedia APIs?</p>

<p><span class='pullquote-left' data-pullquote='model operations that change state as resources on their own'>
In a nutshell the approach is to model operations that change state as resources on their own, not as methods on data resources. CQRS would call such operations <em>commands</em> and the read-only linked data – <em>queries</em>. I will further call them just <em>actions</em> and <em>data</em> respectively. When represented as resources actions can be linked from associated data resources. Furthermore depending on the state of the data and availability of actions according to that state, data resources can decide to either include or exclude particular action links. Now that&rsquo;s a navigable API!
</span></p>

<p>Let&rsquo;s see some actions in action. Consider a resource representing the last 3 calendar events of the user. Depending on whether the event isn&rsquo;t yet in the past the user can either accept or decline it. An already accepted event can be declined and an already declined event can be accepted as long as they still are in the future. Here is a simplistic JSON representation of such a resource:</p>

<div><script src='https://gist.github.com/5591069.js'></script>
<noscript><pre><code>[
  {
    &quot;title&quot;: &quot;Far future&quot;,
    &quot;startsAt&quot;: &quot;2013-01-01 00:00:00Z&quot;,
    &quot;accept&quot;: &quot;http://...&quot;,
    &quot;decline&quot;: &quot;http://...&quot;
  },{
    &quot;title&quot;: &quot;Near future&quot;,
    &quot;startsAt&quot;: &quot;2012-09-01 00:00:00Z&quot;,
    &quot;rsvp_status&quot;: &quot;accepted&quot;,
    &quot;decline&quot;: &quot;http://...&quot;
  },{
    &quot;title&quot;: &quot;Past&quot;,
    &quot;startsAt&quot;: &quot;2012-08-01 00:00:00Z&quot;,
    &quot;rsvp_status&quot;: &quot;declined&quot;,
    &quot;followup&quot;: &quot;http://...&quot;
  }
]</code></pre></noscript></div>


<p>The structure of the event objects and the format of the links are not worth paying attention to at the moment. The point this example tries to illustrate is that the action resources are linked in the same manner as any other resources and their presence in representations depends on the state of the data resources they are linked from.</p>

<p>But is a label and a URL enough to describe an action? An action might accept additional information, like a textual comment in the case of a negative RSVP, or require some other data in order to be executed. Actions also tend to change the state of resources and thus should be activated via an unsafe method like POST. How to express such details in an API directly without a need of out-of-band knowledge? This will be the topic for the next installment of my <a href="http://shishkin.org/blog/categories/hypermedia">hypermedia blog series</a> which hopefully won&rsquo;t take another month to write.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Data/Actions Impedance Mismatch]]></title>
    <link href="http://shishkin.org/blog/data-actions-impedance-mismatch/"/>
    <updated>2012-06-04T15:20:00+02:00</updated>
    <id>http://shishkin.org/blog/data-actions-impedance-mismatch</id>
    <content type="html"><![CDATA[<p>While working on hypermedia APIs recently I came across a very subtle design smell. It manifests itself in excessive usage of CRUD semantics and designing resources after data entities. To anticipate early debate I&rsquo;ll repeat that the smell is very subtle and in some situations the same design may fit well.</p>

<p>Let&rsquo;s consider a valid case first. <a href="http://couchdb.apache.org/">CouchDB</a>, a NOSQL document-oriented database, provides an <a href="http://wiki.apache.org/couchdb/HTTP_Document_API">HTTP API</a> which can be considered restful to a degree: it returns meaningful status codes, respects HTTP caching, uses meaningful HTTP methods. In CouchDB documents and document collections are all resources, they have unique identifiers – URLs, and the client interacts with resources through their representations.</p>

<p><span class='pullquote-left' data-pullquote='none of them exposes any domain logic'>
Another such example is <a href="http://atompub.org/">Atom Publishing Protocol – AtomPub</a>. It has the same uniform CRUD interface over resources, which are collections and items. AtomPub has even nice hypermedia controls &ndash; links, which make it perfectly restful. One common thing about these two API examples is that none of them exposes any domain logic. At most, some CRUD operations may require authorization and basic input parameter validation, but no context-dependent logic.
</span></p>

<p><span class='pullquote-right' data-pullquote='it&#8217;s not a big deal though – database domain logic is just CRUD'>
For a utility API like database or publishing protocol it&rsquo;s not a big deal though – database domain logic is just CRUD. For any but most simplistic API however CRUD is a symptom of an <a href="http://martinfowler.com/bliki/AnemicDomainModel.html">Anemic Domain Model</a>. It is the opposite of the <a href="http://www.codinghorror.com/blog/2007/08/falling-into-the-pit-of-success.html">pit of success</a> that any customer-focused service wants its API to be. But why exactly is that&rsquo;s the case?
</span></p>

<p>If resources are modeled solely after data entities the data versus operations impedance mismatch arises. On the read side everything is fine – given meaningful links between resources, the client can happily navigate all the way through the exposed API data. But as soon as anything needs to be changed the client is left alone with HTTP POST, PUT and DELETE methods, which all have very strict semantics and operate on the resource level. And no, PATCH method is not a solution here, since the problem is not how fine-grained control the client has over data.</p>

<p><span class='pullquote-left' data-pullquote='POST, PUT, DELETE and even PATCH all have too generic semantics to represent any valuable domain operation'>
The problem is that POST, PUT, DELETE and even PATCH all have too generic semantics to represent any valuable domain operation. POST doesn&rsquo;t define how the posted resource representation should look like. PUT means representation replace at its entirety, while PATCH allows partial updates. Though neither PUT nor PATCH can communicate which parts of the representation can be updated or what the user&rsquo;s intent was, making them almost unusable for modeling domain operations. And DELETE is almost never a good business operation (again, data stores and content management systems not considered), if a resource was important enough to be uniquely addressable in the first place.
</span></p>

<p><span class='pullquote-right' data-pullquote='it makes more sense to separate reads and writes at least on the implementation level'>
Not only does complexity grow on the client, the server implementation gets complicated too. The server has to reverse-engineer the lost intent of the user from representation diffs in order to apply domain validation. Different HTTP methods are called in different contexts and require different authorization, but many web frameworks map resource actions to methods on a resource-bound class. This leads to violation of the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">Single Responsibility Principle</a> and is prone to authorization and validation errors. Moreover read and write operations often require different non-functional considerations, so it makes more sense to separate reads and writes at least on the implementation level.
</span></p>

<p>The described problems result in the impedance mismatch between the server and the client. If the client is not a simple forms-over-data, it &ldquo;thinks&rdquo; in domain operations (tasks, actions) for the write part of the domain. A solely data-centric API just doesn&rsquo;t fit there.</p>

<p>I hope to make a case  for the design smell in this blog post and plan to outline a solution in an upcoming post.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[New Blog]]></title>
    <link href="http://shishkin.org/blog/new-blog/"/>
    <updated>2012-06-02T11:06:00+02:00</updated>
    <id>http://shishkin.org/blog/new-blog</id>
    <content type="html"><![CDATA[<p>Welcome to my new blog! You if are curious, <a href="http://shishkin.wordpress.com">my previous blog</a> was hosted on wordpress.com. It was a good ride, but since nothing is more constant than change – it&rsquo;s time to move on. I always wanted to be in full control of my web presence and played with different ideas how to drive my blog further. After a while I just decided to stop evaluation and just start blogging. <a href="http://octopress.org">Octopress</a> happened to become my publishing platform of choice. Let&rsquo;s see how it goes.</p>

<p>To keep updated feel free to subscribe to <a href="http://feeds.feedburner.com/SergeyShishkin">my feed</a>. The feed address remained the same from my previous blog, so if you read this in your feed reader, everything&rsquo;s probably fine as it is.</p>

<p>I intend to blog here about anything <em>I</em> consider valuable around software engineering and software craftsmanship, web architectures and hypermedia, and all things agile. Without further intro fasten your seatbelts and enjoy the ride. To be continued&hellip;</p>
]]></content>
  </entry>
  
</feed>
