So while I agree 400 is the correct response here, I think I differ in the motivation.
For me, if you've submitted a representation that I cannot process for whatever reason then I will respond 400 with helpful advice about why your representation is invalid. So I'd differ from Dan's 400 response like this:
{
"checking_account" : ... ,
{ invalid_content: "checking_account" : ...}
}
That is, it's the representation that is at fault (it fails its "schema" check) rather than being directly mapped to the underlying domain.
Jim
This is a pretty interesting question. The HTTP response codes pertain to HTTP, rather than any underlying domain (they're separate bounded contexts).
I'd differ from Dan's 400 response like this:
{
"checking_account" : ... ,
{ invalid_content: "checking_account" : ...}
}
That is, it's the representation that is at fault (it fails its "schema" check) rather than being directly mapped to the underlying domain.
Jim
On 25 January 2012 12:03, Jim Webber <j...@jimwebber.org> wrote:This is a pretty interesting question. The HTTP response codes pertain to HTTP, rather than any underlying domain (they're separate bounded contexts).Just to stir up this thread a smidge, I'm not sure I agree that they are separate bounded contexts (presumably this is the DDD vocabulary, as per [1]).To put it another way: one can see Rest mostly as a presentation layer of a domain model (at least, I do); and presentation layers are not in a different BC to the domain.
I'd differ from Dan's 400 response like this:
{
"checking_account" : ... ,
{ invalid_content: "checking_account" : ...}
}
That is, it's the representation that is at fault (it fails its "schema" check) rather than being directly mapped to the underlying domain.
I don't particularly object to that representation, however I think it's redundant to mention "checking_account" in the response because (presumably) that identity of the checking account is implied by the resource URL that was invoked.
I would say they are different because while Restis a presentation layer (Resource Model) on top of a Domain Model, HTTP is not your Resource Model. HTTP is the protocol you use to transmit your Resource Model, which is why they should be treated as different contexts.
I'd differ from Dan's 400 response like this:
{
"checking_account" : ... ,
{ invalid_content: "checking_account" : ...}
}
That is, it's the representation that is at fault (it fails its "schema" check) rather than being directly mapped to the underlying domain.
I don't particularly object to that representation, however I think it's redundant to mention "checking_account" in the response because (presumably) that identity of the checking account is implied by the resource URL that was invoked.I don't think a client should use the URL to know what was requested it should be opaque.
So that means you need to use the Content-Type to determine what was returned. With that said I think you would determine to put "checking_account" depending on the Content-Type (aka representation) you are working with. IF you were to useapplication/vnd.resinpractice.Error+json
bounded context:
A description of a boundary (typically a subsystem, or the work of a particular
team) within which a particular model is defined and applicable
I'd counter: A RESTful service meets these requirements: it is not (IMO) simply some aspect of a presentation layer otherwise it would be totally isomorphic to and interchangeable with other "presentation" technologies like SOAP + WSDL. As years of failed frameworks and tooling have shown, this is not the case.
When I build REST services the service layer is very much a separate bounded context from the "domain" layer and exchange information across a well-defined (and therefore testable) boundary.
I believe conflating your integration concerns with presentation issues is wrong. It's equally wrong IMO to conflate integration concerns with your core domain model.
Jim
bounded context:
A description of a boundary (typically a subsystem, or the work of a particular
team) within which a particular model is defined and applicable
[snip]
When I build REST services the service layer is very much a separate bounded context from the "domain" layer and exchange information across a well-defined (and therefore testable) boundary.
I believe conflating your integration concerns with presentation issues is wrong. It's equally wrong IMO to conflate integration concerns with your core domain model.
Jim