Friday, February 29, 2008

Declarative Programming Recipes

If you've been using an imperative programming language such as Java, C#, or JavaScript, then you should consider the benefits of declarative programming when designing your next application. In this blog, I will explore the benefits of the following technologies:

  • XML Schema
  • ISO Schematron
  • XForms/XBL (XML Binding Language)
  • XSLT 2.0
  • XQuery
  • Atom Syndication
  • AtomPub

The basic difference between declarative programming languages and imperative programming languages such as C# and Java is that the former specify the “what” (the intent) as opposed to the “how” (the algorithm). The following are some reasons to consider this new paradigm:

  • Declarative programming languages are accessible to many non-programmers
  • It’s possible to create a solution that is completely declarative (no Java, C#, JavaScript, or AJAX code)
  • It facilitates the Model-Driven Architecture (MDA) software design approach
  • When the data or content is managed in XML, a declarative programming model is a superior and simpler alternative to a conventional approach based on Java Server Faces (JSF), Spring, and Hibernate. For example, you get a more robust and simpler data and business rules validation mechanism and you can forgo ORM mapping altogether. However, declarative and imperative programming can co-exist in the same solution.

The following are some recipes for taking advantage of this new paradigm:

  • Define your data structures and types in the XML Schema.
  • Use XML Schema's xsd:appinfo element to:

    • Capture metadata such such as XML to RDBMS mapping information
    • Capture business rules using inline ISO Schematron rules
    • Control the labels, alerts, and appearances of UI components such as XForms controls.

  • Generate your UI by transforming the XML Schema into XForms with XSLT.
  • Alternatively, store your XML schema and other XML-formatted metadata artifacts in a native XML database and use XQuery to extract and manipulate the metadata during development and at run-time.
  • Use XBL for enabling custom UI controls for your XForms. As an example, you can integrate a rich text editor using XBL and Dojo.
  • Use ISO Schematron for business rules validation either post form-submission or by using XSLT to inject schematron rules into the XForms directly with the xforms:bind element.
  • Use the RESTful or AtomPub API to a native XQuery-enabled XML database (such as Exist) to CRUD (create, read, update, delete) the data.
  • If you're using SOAP-based web services, use XForms to send SOAP requests and display SOAP responses as well.
  • Leverage Atom syndication for pushing updates to data consumers. In general, when creating your application, think "Syndication Bus".

Many software architects and developers are not yet aware of the power of this new paradigm. However, I believe that rather than using only familiar development frameworks, it’s important to always evaluate emerging alternatives and select the best approach even it involves a learning curve.

Saturday, February 2, 2008

Open Source and the Democratization of Knowledge

I like Open Source Software (OSS) for a number of reasons. It lowers the cost of software and allows a larger number of organizations and individuals worldwide to make use of it. OSS is also where real innovation is currently happening in the software industry. OSS companies focus their resources on the engineering process and use the web itself as a marketing and distribution channel. This allows users to freely download and try the product and decide for themselves if it’s good for them. They can get free support from the community of users or purchase commercial support for mission critical applications. The quality of product can be quickly enhanced because of the feedback that the OSS developer gets from the potentially thousands of users who download the software.

But the most important reason why I like OSS is that it enables what I call the democratization of knowledge. Complex software like operating systems, databases, ERP, CMS, and web portals all exist today in OSS. OSS is a great equalizer because anyone can access the source code to learn or discover how such complex systems are designed. They can also contribute to the code if they wish. This is unprecedented in human history. Traditionally certain groups of people have kept their technological know-how to themselves as a competitive advantage used to dominate and control markets and/or other groups of people.