Metadata, Pattern Implementation, and Customization
Andy Kramek put together a fantastic blog entry earlier today, titled “Creating Classes with a Factory“. This type of design pattern belongs to the Creational family of patterns, and is used mainly to, um, create things!
What I really like about Andy’s entry is his emphasis on metadata to accompany the pattern. He writes: “[metadata] is what makes this implementation so useful in my opinion, and why VFP is such an ideal tool in which to implement this particular pattern”. And of course, he’s absolutely right!
But more importantly, Andy has uncovered a very useful function of metadata that can be applied to many other elements of software development. That is, the ability to use metadata to store code snippets that can be updated or tested by developers while the executable is running. This isn’t only a handy time-saver, but it’s also a great way to compartmentalize code, deliver custom functions to clients, and build robust and scalable solutions. By including code in memo fields, you can customize applications without changing the core engine. And, as Andy pointed out, you can test various implementations while running the executable.
I’ve used this approach for many years; for as long as EXECSCRIPT has been around. I’ve used to it generate SQL statements on the fly, run conversion routines (some clients like data stored using inches, while others prefer millimeters for example), and separate complex and specialized algorithms that have different implementations depending on the client. I rely on it heavily for all my data integration tasks. In fact, logical data maps (which are more than just “logical” in my world) are used solely to drive all data transformations — not a single piece of business logic is included in the application. The alternative to the metadata approach is to embed these things into the source code itself — but in my experience, this just leads to greater maintenance, regression headaches, and clients that need to wait a little longer.
Using metadata allows you to separate functionality from implementation. In the case of Andy’s Factory pattern, this is one of his important bullet points. In Visual FoxPro, we have the luxury of an in-house, native database that is fast and easy to use. Perfect for metadata (even if you’re using some other database for the backend).
I'm a Quant Technical Specialist (Data Warehousing and Business Intelligence), with expertise in business analysis, data modeling, and data integration. I have extensive experience developing vertical and integrated desktop, Internet, and BI applications spanning municipal, clinical, and financial industries.

August 7th, 2007 at 1:54 pm
I think it’s also worth mentioning that this is made easier in VFP by the fact that it’s a dynamic vs. strong typed language so late binding and loose coupling are much, much easier to accomplish. I still think this, even more than the DBF or cursor, are what make it hard to switch to something like .NET where we must use fancy terms such as Reflection and Generics to even come close to accomplishing dynamic code at runtime. Of course, the strong type camp will say their code is more bug free, but that argument only applies if you’re a lazy programmer.