Blog

API as remote Model

2009-04-15 15:38:05 by Martynas Jusevičius

When developing with the DIY Framework we're using internal XML serialization of objects, and XSLT stylesheets as templates.
I'm not proud of the serialization code, it started as a quick hack to get the data into a usable format, and has improved only a little since then. It is building XML on a string level, when in fact it should be using DOM for that. Object serializations retain their database IDs, on which later they can be joined in the stylesheet from several XML documents.

Later I was developing a RESTful API to publish XML intended to be public and used remotely, not internally. Then I caught myself producing yet another serialization of Model objects using DOM, which was based on HTTP principles and resource URIs.

I soon realized that I was doing a double job, and that a single XML serialization could serve both purposes. It should be based on the API version, i.e. employ URIs and not IDs (and use DOM of course). I would have to adjust the stylesheets (especially joins) accordingly, but that should not be that hard, because both serializations are only supporting 2 general types of content: list of items (array), and a single item.

A useful outcome of such architecture would be that the API would effectively serve as the Model (as in MVC), either internally or remotely. On the other hand, the XSLT stylesheets would also become decoupled, they could be used on the server-side as well as the client-side. They would use internal XSLT processor calls to retrieve the necessary XML documents in the first case, and remote HTTP calls to the API in the second.

Digg Digg this! del.icio.us del.icio.us!

Comments (1)

2010-01-25 12:14:06 by mcitp certification

Blogs are always a main source of getting accurate information and provide you the handy results; you can get instant and reliable information which surely helps you in any field of your concern. I am post graduate in IT and HR. These days I am doing preparation of different online certifications and I found exam guides guide is the best helping source which is providing 100% authentic material. I also spend my extra time in surfing internet, listening music and playing games. After my exams I would like to join your group.

Regards
Marry Davidson

New comment






No HTML allowed.