Skip to content

Commit

Permalink
adding hypermedia format
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermesilveira committed Dec 27, 2010
1 parent 422079c commit 762b195
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 44 deletions.
4 changes: 2 additions & 2 deletions site/app/controllers/systems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ def benefits
end
def support
end
def rest
end
def features
end
def quit_pretending
end
def hypermedia
end
end
77 changes: 43 additions & 34 deletions site/app/views/systems/hypermedia.html.erb
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
<div id="contentWrap">
<h3>Hypermedia representations</h3>
<style>
pre { font-size 11px; color: #666; margin-bottom: 10px; margin-top: 10px; font-family: 'Courier New', 'Courier';}
h3 { margin-top: 20px; font-size: 20px !important;}
</style>

<p>
The following is a typical webservice xml representation using POX, and would be even bigger if it was using SOAP and the WS-* stack:
<div id="contentWrap">
<div id="contentBeneficios">
<a rel="nofollow" name="what_is_rest"></a>
<h2>Why hypermedia</h2>
<h3>Typical SOA?</h3>

<pre>
<%=html '<flight>
<p>
The following is a typical webservice xml representation using POX, and would be even bigger if it was using SOAP and the WS-* stack:

</p>
<pre><%=html '<flight>
<from>sao paulo</from>
<to>seoul</to>
<seats>2</seats>
<price>1600.00</price>
</flight>
'%>
</pre>

Any clients consuming this representation should know before hand where to make their payments to. If they want to change the amount of seats, the clients also need to know where to send the new information: all the URIs and fields are known before hand.
</flight>'%>
</pre>
<p>
Any clients consuming this representation should know before hand where to make their payments to. If they want to change the amount of seats, the clients also need to know where to send the new information: all the URIs and fields are known before hand.

There is a coupling between *all* web services that your client is going to access even before it touches the first service (our entry point).
There is a coupling between *all* web services that your client is going to access even before it touches the first service (our entry point).

This means that if our service wants to delegate the payment control (or any other part) to a third party payment system, it needs to change all existing clients: the coupling that WS-* stack provides us is nasty.
This means that if our service wants to delegate the payment control (or any other part) to a third party payment system, it needs to change all existing clients: the coupling that WS-* stack provides us is nasty.

<h3>ESB?</h3>
<h3>ESB?</h3>

Using ESB's would help, while at the same time centralizing control in one place means losing the ability to run clients everywhere on the web. Systems created in 2010 which think they are not going to require clients on the web on the future will have to be updated soon: the web is already our platform.
Using ESB's would help, while at the same time centralizing control in one place means losing the ability to run clients everywhere on the web. Systems created in 2010 which think they are not going to require clients on the web on the future will have to be updated soon: the web is already our platform.

Knowing URIs before hand is similar to the Service Locator pattern:
Knowing URIs before hand is similar to the Service Locator pattern:<br/>

<%= image_tag "service.png", :title => "Service Locator" %>
<%= image_tag "service.png", :title => "Service Locator" %><br/>
</p>

<h2>Hypermedia changing the picture</h3>
The first, but far from last, step is to add hypermedia controls to our representation. In this case, we will add some links:
<h3>Hypermedia changing the picture?</h3>
<p>
The first, but far from last, step is to add hypermedia controls to our representation. In this case, we will add some links:

<pre>
<%=html '<flight>
<pre>
<%=html '<flight>
<from>sao paulo</from>
<to>seoul</to>
<seats>2</seats>
Expand All @@ -42,21 +50,22 @@ The first, but far from last, step is to add hypermedia controls to our represen
<link rel="self" href="http://myservice/flight/235" />
</flight>
'%>
</pre>
</pre>

Since our client's inception, their code is already capable of navigating through those links and whenever those services point to something else, all clients will be capable of adapting themselves with no line of code changed.
Since our client's inception, their code is already capable of navigating through those links and whenever those services point to something else, all clients will be capable of adapting themselves with no line of code changed.

Of course, there is the need to use a common, well known, format: even better, a well known and accepted media type or micro formats.
Of course, there is the need to use a common, well known, format: even better, a well known and accepted media type or micro formats.

Using hypermedia controls to let clients navigate through your service status is to dependency injection as typical webservices (and POX) is to service locator.
Using hypermedia controls to let clients navigate through your service status is to dependency injection as typical webservices (and POX) is to service locator.<br/>

<%= image_tag "dependency.png", :title => "Dependency Injection" %>
<%= image_tag "dependency.png", :title => "Dependency Injection" %><br/>

At this point you have been convinced that hypermedia gives up lesser coupling between consumers and services than typical web services using SOAP and the WS-* stack.
</p>
At this point you have been convinced that hypermedia gives up lesser coupling between consumers and services than typical web services using SOAP and the WS-* stack.
</p>
<h3>Why not URI patterns?</h3>

<h2>Why not URI patterns?</h2>

Knowing URI patterns offers the same type of coupling to only one service provider as knowing all URIs. Opensearch is an example of URI patterns that allows service provider to teach clients so the coupling is minimized.

</div>
<p>Knowing URI patterns offers the same type of coupling to only one service provider as knowing all URIs. Opensearch is an example of URI patterns that allows service provider to teach clients so the coupling is minimized.
<br/><br/><br/><br/>
</p>
</div>
</div>
8 changes: 4 additions & 4 deletions site/app/views/systems/quit_pretending.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div id="contentWrap">
<!--<ul id="subMenu"><li><a href="#beneficios">Beneficios</a></li><li>|</li><li><a href="#depoimentos">Depoimentos</a></li></ul>--> <div id="contentBeneficios">
<a rel="nofollow" name="what_is_rest"></a>
<h2>Quit pretending</h2>
<h3>Painful maintenance?</h3>
<div id="contentBeneficios">
<a rel="nofollow" name="what_is_rest"></a>
<h2>Quit pretending</h2>
<h3>Painful maintenance?</h3>

<div class="depoimentoClientes">
<p>We all have been through it. Whenever some minimal changes are made in your service, all your clients break, and they are already complaining.</p>
Expand Down
4 changes: 0 additions & 4 deletions site/app/views/systems/rest.html.erb

This file was deleted.

0 comments on commit 762b195

Please sign in to comment.