background preloader

REST Anti-Patterns

REST Anti-Patterns
When people start trying out REST, they usually start looking around for examples – and not only find a lot of examples that claim to be “RESTful”, or are labeled as a “REST API”, but also dig up a lot of discussions about why a specific service that claims to do REST actually fails to do so. Why does this happen? HTTP is nothing new, but it has been applied in a wide variety of ways. Some of them were in line with the ideas the Web’s designers had in mind, but many were not. Applying REST principles to your HTTP applications, whether you build them for human consumption, for use by another program, or both, means that you do the exact opposite: You try to use the Web “correctly”, or if you object to the idea that one is “right” and one is “wrong”: in a RESTful way. For many, this is indeed a very new approach. As with any new approach, it helps to be aware of some common patterns. Let’s start with a quick list of anti-patterns I’ve managed to come up with:

Sammy What Sammy is a tiny javascript framework built on top of jQuery. It’s RESTful Evented JavaScript. Why jQuery is probably the fastest, most robust way to abstract basic low-level Javascript functionality that every Javascript developer needs. Working heavily with Sinatra, I realized that the simple route definitions and structure it provided could be a great fit with jQuery/JavaScript. I started off on this project thinking “It would be cool to implement Sinatra in JavaScript”. I see Sammy as a great way to build simple to complex applications built upon RESTful data stores like CouchDB or Cloudkit. Basics A Sammy application revolves around ‘routes’. You set up a Sammy Application by passing a Function to the $.sammy (which is a shortcut for the Sammy.Application constructor). $.sammy(function() { this.get('#/', function() { $('#main').text('Welcome!') Inside of the ‘app’ function() this is the Application. Above, we defined a get() route. var app = $.sammy(...) More!

Part 1: Introduction to Jersey--a Standard, Open Source REST Implementation By Julien Dubois, June 2010 Introduction This article is part 1 of a four-part series. In part 2 of this series, we will look at JQuery, a popular JavaScript framework. Note: This article was written and tested using NetBeans IDE 6.8. REST and Jersey REST is an architectural style defined by Roy T. It is beyond the scope of this article to describe REST in detail, but to summarize, the idea is that clients and servers communicate by sending and receiving representations of resources. An HTTP GET request to receive a resource An HTTP POST request to create a new resource This might look fairly low-level to a Java developer. REST is just an architectural style, not a technology. There have been several implementations of this standard. Building the Sample Application Quickly with NetBeans and JavaServer Faces We are going to build the sample application step by step, but if you want to take a look at the final application, you can download its source code here. Testing the REST Application

.Net Mocking Frameworks - Capability Comparison | PHP vs .Net I have a couple years of experience of TDD under my belt, but it's only recently that I've felt like I am a relatively decent practitioner of it. I attribute this to forcing myself to take the plunge into mocking, and the knowledge of patterns and loosely-coupled design that I've gained from it. You see, I work on a pretty large and complex ASP.Net webforms product, and tests were introduced late into the development cycle of the initial release. We favored integration testing with real data sources over actual unit tests. While I did write some tests, I knew that our product was not very testable by design. Recently we put together a public facing API for programming against the product, that we were able to build from scratch. Several weeks down the road, it was obvious that Rhino just isn't right for our environment. This led me on a frustrating research mission to find the differences between frameworks without actually trying them all. .Net Mocking Framework Comparison Other Notes

Unifying Web "Sites" and Web Services with the ... By aaron|asp.net, tools, web services (For those who’d rather just download the code, the link is at the end.) Lately I’ve been delving into the ASP.NET MVC framework, the timing of which has been interesting as I am about to finish reading RESTful Web Services by Leonard Richardson and Sam Ruby. It’s an excellent book that I’d highly recommend to anybody designing and creating services for the web, or just interested in it. This quote from the book description on Amazon.com succinctly describes what’s been floating around in my head for a while: You’ve built web sites that can be used by humans. Why do we have to build web "sites" for humans and different web services for machines? With the ASP.NET MVC Framework, though, I see the opportunity to unify services and "sites" (human-readable services). The separation of concerns and extensibility that the ASP.NET MVC framework exposes lets us accomplish this with surprisingly little code. Approach I tend to agree with that. Implementation

Service oriented REST architecture is an oxymoron It is infrequent for me to react with a level of consternation rather than agreement or disagreement that I felt upon reading [SOA] Boris on Service, Web and REST by Jean-Jacques Dubray. Not because I disagreed strongly with the arguments presented. It is that, I disagree substantially with the assumptions on which these arguments are made. And yet, as I recollect my own thoughts a year ago - a few months post my journey into REST, I realised that there was a time that I did actually believe some of these assumptions. I also realised that it is likely that many others who are dealing with a transition from SOA to REST are also likely to be perhaps sharing similar assumptions. Service orientation is neither essential for, nor is it the intention of REST. There. I say not surprisingly because RESTafarians have no clear position on "service", they just say REST is the right way to build a Service Oriented Architecture. and it further goes on to state Service Resources You cheated!

A Brief Introduction to REST You may or may not be aware that there is debate going on about the “right” way to implement heterogeneous application-to-application communication: While the current mainstream clearly focuses on web services based on SOAP, WSDL and the WS-* specification universe, a small, but very vocal minority claims there’s a better way: REST, short for REpresentational State Transfer. In this article, I will try to provide a pragmatic introduction to REST and RESTful HTTP application integration without digressing into this debate. I will go into more detail while explaining those aspects that, in my experience, cause the most discussion when someone is exposed to this approach for the first time. Key REST principles Most introductions to REST start with the formal definition and background. Give every “thing” an ID I’m using the term “thing” here instead of the formally correct “resource” because this is such a simple principle that it shouldn’t be hidden behind terminology. Link things together

James Carr » Blog Archive » TDD Anti-Patterns Recently I began to write a paper on TDD Anti-Patterns, and decided to first quickly jot down some of the most common ones that others or myself have encountered “in the wild.” I then posted what I had on the testdrivendevelopment on yahoogroups mailing list, and got an excellent bit of feedback! As a side note, keep in mind this is merely a catalog at the moment, hopefully to be expanded in full down the road. TDD Anti-Pattern Catalogue The Liar An entire unit test that passes all of the test cases it has and appears valid, but upon closer inspection it is discovered that it doesn’t really test the intended target at all. Excessive Setup A test that requires a lot of work setting up in order to even begin testing. The Giant A unit test that, although it is validly testing the object under test, can span thousands of lines and contain many many test cases. The Mockery Sometimes mocking can be good, and handy. The Inspector Generous Leftovers [4] The Local Hero [1] The Nitpicker [1] The Dodger [1]

MVC Contrib - MvcContrib.org - Home Calculus -- web-calculus Calculus This specification defines an application interface model, the web-calculus, that is independent of the application programming model. The model enables reasoning about the functionality and security of an application interface. Abstract The web-calculus is defined over a directed graph. Overview Design goals Access control is expressed through the capability-based security model. Capability-based security The web-calculus operates on a directed graph. Meta-model Many different application programming models exist, each with its own unique constructs. Partial understanding Many useful applications can operate on a graph using only partial understanding of the nodes in the graph. Interface refactoring Many existing security models operate in terms of statically defined authority bundles. Adapting an application with static authority divisions to a new usage requires the creation of protection proxies. Description The interface model defined by the web-calculus need not be reified.

Related: