The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Share Schema, not Type - Explained?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Scott Hanselman

Posts: 1031
Nickname: glucopilot
Registered: Aug, 2003

Scott Hanselman is the Chief Architect at Corillian Corporation and the Microsoft RD for Oregon.
Share Schema, not Type - Explained? Posted: Nov 2, 2003 9:07 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Scott Hanselman.
Original Post: Share Schema, not Type - Explained?
Feed Title: Scott Hanselman's ComputerZen.com
Feed URL: http://radio-weblogs.com/0106747/rss.xml
Feed Description: Scott Hanselman's ComputerZen.com is a .NET/WebServices/XML Weblog. I offer details of obscurities (internals of ASP.NET, WebServices, XML, etc) and best practices from real world scenarios.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Scott Hanselman
Latest Posts From Scott Hanselman's ComputerZen.com

Advertisement

Steve Maine posted in my comments section in response to a fellow who asked “What do you [folks, Doug Purdy, Don Box] mean by 'Share Schema, not Type'?

Here's my answer:

Types are immutable and unique. Like, Scott.Hanselman.Corillian.Whatever.  That's a unique type, especially when you add the concept of public keys.  If you wanted to use it, I'd need to give you the Assembly.

If we share "schema" then you could consume some XML that you and I agreed
upon - like a contract.  Then you can have Phil.Whatever.Yahoo.SomeOtherType that can consume the SAME XML (the contract) and think about it some other way.  The Schema is shared, not the type.

Here's Steve's answer:

Good question. Certainly, XSD and the CTS (the .NET type system) are both things that you can use to define "types", and there's quite a lot of work that goes into marshalling data between those two different worlds. To get at the difference between schema and type, it's easiest to look at where we came from back in the olden days of COM.

In COM, two components communicated by sharing interface definition. COM interfaces defined a strict binary layout in memory. COM interfaces were uniquely identified by IID's and commonly defined in shared metadata via type libraries. The end result of this was that I could walk up to you and say "Here is an IFoo, its IID is XXX and it's defined in this .tlb file" and you would know *exactly* what the vtable layout of that interface would look like in memory.

Because they were based around this idea of a binary specification of vtable layout, COM interfaces could only define methods. That is, they presented a set of behaviors to a consumer. Some of those behaviors might be to manipulate an object's local state via methods like GetXXXValue and SetXXXValue, but they were still behaviors nonetheless. Thus, when I walk up to you with a COM interface, I'm essentially telling you "here's the set of things that I can do".

This lead to all sorts of problems. It was very difficult to ensure semantic consistency across interface implementations because there was no way to contractually specify what an interface method was actually supposed to do -- COM interfaces told you how to call methods, but they didn't tell you what effect calling those methods will have. Another problem with COM interfaces was that they were immutable once published. If you wanted to add a member to a published interface, you had to create a whole new interface. That's why we get things like IDispatch2Ex -- COM interfaces just didn't grow very nicely.

Web services attempt to solve these problems by communicating in terms of schemas and contract. A schema is a description of the legitimate contents of a message. It communicates only state, and says nothing about behavior. For example, a person schema allows to mechanically verify assertions like "I am expecting a Person, and that Person will at least have FirstName and a LastName." There is nothing in the schema that says what that person can *do*, because it really can't do anything -- it's just a blob of structured stuff. Furthermore, if these schemas are designed to take advantage of XML's intrinsic support for open content, people can evolve these schemas transparently without breaking old systems.

Contracts are the way that web services describe their behaviors. Contracts are used to define the legal patterns of messages that two services may exchange. For example, a contract for a purchase ordering system might be a mechanically verifiable expression of the idea that "if you send me a Purchase Order message(defined by the PurchaseOrder schema) and I can successfully process it, I'll send you back a Purchase Order Filled message (defined in the PurchaseOrderFilled schema). By contractually specifying the legal sets of inputs and outputs to a system, web services help ensure consistent semantics across services (which is something that COM could never do).

In summary, a type is a closed encapsulation of state+behavior. A schema is a potentially open description of state, while a contract is a description of the messaging patterns that define service behaviors.

Read: Share Schema, not Type - Explained?

Topic: InfoBits from PDC III Previous Topic   Next Topic Topic: PDC - Attendee Party @ Universal Studios

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use