W3C home > Mailing lists > Public > public-opentag@w3.org > May 2012

Re: distinguishing between 'description URLs' and 'interface URLs'

From: Michiel de Jong <michiel@unhosted.org>
Date: Wed, 9 May 2012 13:23:01 +0200
Message-ID: <CA+aD3u3PLdLKiy4fWeVPD=Pgy+8py4+6M0g5_4zDN0CjGHj52g@mail.gmail.com>
To: Marcos Caceres <w3c@marcosc.com>
Cc: public-opentag@w3.org
On Wed, May 9, 2012 at 12:35 PM, Marcos Caceres <w3c@marcosc.com> wrote:
> Can you provide more details? I'm puzzled as to when you would need to get to such a level of abstraction in an application?

sure! say I have an app that consumes linked data and displays
biographical information about people. It deals with people, documents
about those people, and contact addresses of those people.

it starts with one document retrieval URL retrieves that, and then
follows links. While spidering the documents it keeps track of two
data structures: people and documents. both the Person class and the
Document class inherit from the Thing class.

The Thing class has a private property 'URI', which is defined as 'the
URI of the thing' and is set in the constructor. It then has a public
method getContents() that retrieves the thing from the web, *if* the
URI is a retrieval URI.

If the URI is a URN, a description URN, an interface URN, or an
interaction URL, then getContents() should throw an exception,
something like 'cannot get contents when retrieval URL is unknown'.

The Thing class might also have a getDescription() method that throws
an exception whenever no description URN is available (it would also
throw an exception when a network error occurs, but that's a different

Conclusion: the constructor for the Thing class cannot just take an
argument URI: the URI of the thing. it needs to take two arguments:
URI, and URI-Type, where URI-Type is one of the 5 options i proposed.

You could create subclasses 'RetrievableThing', 'DescribedThing' etc,
and put the getContents() and getDescription() methods on there
instead of putting them directly on the Thing class.

But can software work without this level of abstraction? Maybe,
partially. You could write the rest of the classes in such a way that
they only call getContents on Documents and never on Persons. Or you
could just try to retrieve a person's contents --- their stomach,
etcetera ;) --- and then see how far you get. But that would be
against all software design common sense IMO.

If we use terms to mean certain things, then we should call them that
in our source code, and make sure each module is in itself sound and
correct. So to make the Thing class correct, and be able to write unit
tests for it, i need that distinction.

I do not know how i could write an object-oriented software
application that crawls biographies, without referring to the
difference between getDescription() and getContents() in the design.
how would you do it?

Thanks for thinking along with this!

Received on Wednesday, 9 May 2012 11:23:32 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 19:35:46 UTC