[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: include multiple utility modules vs one larger one

Subject: RE: include multiple utility modules vs one larger one?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 12 Mar 2009 10:43:52 -0000
RE:  include multiple utility modules vs one larger one
> The compiler we're using produces "warnings" about circular 
> references which we took to mean they were inefficient, bad 
> or otherwise to be avoided.

Circular imports and includes are fatal errors. The compiler has no business
giving you a warning, it should reject the code as incorrect.

You never need circular imports and includes, because a module doesn't have
to import/include everything it is dependent on. 

This doesn't just mean that the import/include graph should be acyclic, it
also means it should be a tree rather than a lattice. A lattice structure
isn't intrinsically an error, but it can cause errors (especially in the
case of include) because it generates multiple objects (e.g. functions) with
the same name; and it can also cause inefficiencies due to having multiple
copies of the same code (typically template rules).

If you want maximum flexibility to use a module in different stylesheet
configurations, it's probably best if it doesn't import/include anything,
but merely documents its dependencies. It's then the job of the top level
stylesheet module to include/import enough to ensure that all the
dependencies are satisfied. 

I think it's unlikely that performance should ever be a deciding factor, or
even an influencing factor, in determining how you modularise your code.
It's not impossible - a few years ago I encoutered a stylesheet that
performed pathologically badly in Saxon because it contained thousands of
unused global variable declarations (problem long since fixed). But you'll
only find such issues by making measurements, not by theorising about them.

Michael Kay
http://www.saxonica.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.