.NET Brain Droppings

I'm a Microsoft Certified Architect (MCA)... Feel free to ask me about the program...

Defining Service Contracts with Angle Brackets... Yes/No?

Below is a copy of an email I sent to a buddy in Redmond (feel free to take a guess as to who it is).  He's *very* against using XSD to define a service contract.  I, on the other hand, am for it (though I have to say that he and others are beginning to sway me).

Anyone out there have any opinions?  I'll post his response later because I want some honest feedback on this one.  I'm about to define the architecture for a pretty large app, and the decision I make now I will have to live with for a  l o n g  t i m e...

<emailSnip>

So let me run this by you.  I'm always open to opinions/critique...

-- If there's one thing I learned from doing VB.COM back in the day it's that using a programming language to define a interoperable, *language agnostic* interface can get you in trouble.  The tendency to define concepts that are not understood by all consumers of the interface is to great.  I understand that I am (very) loosely comparing Indigo to VB.COM, but theoretically the same issue exists.  I understand there is a perfectly valid counter argument saying that you can define concepts in XSD that are not supported by all languages, but these are edge cases that are rarely an issue (substitution groups come to mind).

-- I don't have to see pointy brackets anymore.  Tools like XMLSpy are getting better and better at abstracting away the pointy brackets.  In fact, XMLSpy is getting close to being a DSL for defining the aforementioned interoperable interface.   :)

-- The idea behind this whole contract-first hoo ha is that we define contracts, that represent documents that are passed from consumer --> service --> and (maybe) back.  IMHO, there is no better (or more natural) method for creating a document definition than XSD.

-- I also love the fact that I can expose a XSD on a server-side endpoint and a consumer is free to use it in order to gain access to cursory business logic that would otherwise cost them a round-trip to the server.

Example:
        int withdrawalAmount; // This could be 450,000
Vs.
        <element name="withdrawalAmount">
                <simpleType>
                        <restriction base="positiveInteger">
                                <maxExclusive value="400"/>
                        </restriction>
                </simpleType>
        </element>
My ATM limit per transaction is 400 bucks.  In the XSD world, I can push that constraint down to the client for validation prior to sending me the entire document.  Additionally, to validate it on the server, I don't have to write trivial code such as:

If(withdrawalAmount > 400) return false;
That stuff is handled for me by the schema validator.

</emailSnip>

Thoughts?

[Listening to: The Bravery - Unconditional]

 

Comments

Ruslan Popov said:

> using a programming language to define a interoperable, *language agnostic* interface can get you in trouble

AGREE.


> pointy brackets

"<" and ">" ? I don't think that is a problem. The features and the concept of XSD (its OOrientation, extensibility, and much much more) are important. And as said, software tools abstract you from the actual representation of schemas, in fact, you may work much with them and never see how their code looks like.


> we define contracts, that represent documents that are passed from consumer --> service --> and (maybe) back.

Yes, and more. IMO, XSD is a good mean to define business objects even if they are not going to be passed anywhere at this point. And if later you decide to exchange those objects with other systems XSD turns very handy.

> IMHO, there is no better (or more natural) method for creating a document definition than XSD.

I would say, "I don't know a better method". If someone knows, let me know. :)

XSD is good, but what it is being compared to? What does your friend propose instead?
# April 21, 2005 3:29 AM

IM said:

Does XSD do 'value must be a multiple of 20', for when there's no 10's in the ATM?
# April 21, 2005 3:45 AM

Ruslan Popov said:

> Does XSD do 'value must be a multiple of 20', for when there's no 10's in the ATM?

That's a business rule, so it is not a "subject" of XSD, AFAIK. Maybe that can be defined with OCL and embedded into an XSD - no problem. What would you propose instead?
# April 21, 2005 4:11 AM

Defining Service Contracts with Angle Brackets… Yes/No? | Reference said:

Pingback from  Defining Service Contracts with Angle Brackets&#8230;  Yes/No? | Reference

# January 16, 2008 10:43 AM

21JaneFrakloop said:

Great article to my mind. Keep it up!

21Jane Frakloop

<a href="californiaescortagency.com/">asian escorts in ca</a>

# October 1, 2011 4:19 PM

MarryBodge said:

Nice stuff to my mind. Keep it up!

Marry Bodge

<a href="californiaescortagency.com/">ebony escorts in california</a>

# October 1, 2011 7:40 PM

RoseCamson said:

Wonderful post as for me. Keep writing such stuff!

Rose Camson

<a href="black-escort-london.com/">call girl black</a>

# October 29, 2011 7:46 PM

KateGunish said:

Wonderful article to my mind. Keep it up!

Kate Gunish

<a href="cyprusescorts.us/">escorts cyprus independent nicosia</a>

# October 29, 2011 11:18 PM

21Jane23Wilson said:

Great post imho. Keep posting this way!

21Jane 23Wilson

<a href="cyprusescorts.us/">Limassol escorts</a>

# November 2, 2011 4:30 PM

AnnaBodge said:

Wonderful post as for me. Keep posting such stuff!

Anna Bodge

<a href="dubai-escort.com/">dubai escorts services</a>

# November 5, 2011 5:11 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)