aspose file tools*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Query on use of inheritance using restriction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Query on use of inheritance using restriction " Watch "Query on use of inheritance using restriction " New topic
Author

Query on use of inheritance using restriction

Abhishek Dharwadkar
Ranch Hand

Joined: Aug 02, 2006
Posts: 44
whats the real use of restriction?

Why cant we just declare a new type? I dont understand...

Could someone please help


"I may not have gone where I intended to go, but I think I have ended up where I needed to be"<br /> <br />"He felt that his whole life was some kind of dream and he sometimes wondered whose it was and whether they were enjoying it"<br /> <br />--by Douglas Adams<br /> <br />[SCJP - 96%, SCWCD - 88%, SCBCD - May 2008]
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Originally posted by Abhishek Dharwadkar:
Why cant we just declare a new type?


Of course you can.

In fact Nicolai Josuttis states in SOA in Practice: The Art of Distributed System Design (p44):
Based on my own experience (and others), I recommend that you have a basic set of fundamental types that you can compose to other types (structures, records) and sequences (arrays). Be careful with enumerations (an anachronism from the time when each byte did count - use strings instead), inheritance and polymorphism (even when XML supports it).


However the concept of restriction is supposed to help eliminate duplication from the schema.

Also restriction isn't inheritance in the polymorphic sense - i.e. you can't always use the derived type in place of the parent-type because the derived type is more constrained than the parent type. Restriction is used to create new types by placing additional constraints on an existing type - the existing type is often a base XML type. For example:

a lower case alpha string with at least 6 but no more than 8 letters


an integer with an allowable range of 0-99


constrained temperature types
Suryakumar Surendran
Ranch Hand

Joined: Jan 30, 2008
Posts: 38
Thanks Peer


SCJP 1.4 | SCWCD 1.4 | now preparing for SCDJWS
Abhishek Dharwadkar
Ranch Hand

Joined: Aug 02, 2006
Posts: 44
Thanks Peer for such a good explanation
 
Don't get me started about those stupid light bulbs.
 
subject: Query on use of inheritance using restriction