The Waffle Generator

Comments 0

Share to social media

Waffle

This article provides the source of a utility, the Waffle Generator, which will fill your database or website with ridiculous and turgid prose. This is not, as you might initially suspect, designed as a crutch for desperate Bloggers, but to test out software. The perfect test data is as much like the real data as possible, but rather wilder, and more random.

In this article, I provide the source for both a PHP version and a C# version of the Waffle Generator. I also show you how to make it into a custom generator for the new SQL Data Generator.

A Brief History of the Waffle Generator

I originally wrote the Waffle Generator way back in the mid 1980s, long before the Web. I started work on it when I first met the redoubtable ‘Phil Factor’. Even then, he had a strong anarchic streak to his nature. We were working in a large Multinational together, and both driven to screaming pitch by the poor use of English in company documents, marketing information, and in IT discussions and meetings. We developed our collection of words and phrases by noting down the ridiculous examples used in meetings during our work there as IT consultants, and incorporating them into the collection.

Based on this word bank, The Waffle Generator produces reams and reams of text which, on first glance, looks like real, ponderous, prose; replete with clichés. The following paragraph typifies its output (try it for yourself here: Press F5 occasionally!).

‘Regarding the nature of any three-tier subjective classification, the total delivery presents extremely interesting challenges to the sanctioned Philosophical theme. The interface is of a interactive nature. To reiterate, the classic definition of the consolidation of the interpolation of antithesis underlines the essential paradigm of the negative aspects of any marginalised interface. It might seem reasonable to think of a proven solution to the performance objectives as involving the legitimate principal milieu. Nevertheless, a concept of what we have come to call the strategic goals provides a heterogeneous environment to the evidence of feeling. On the other hand, a realization the importance of the core business is reciprocated by the negative aspects of any proactive auxiliary teleology. There is probably no causal link between the three-phase empirical transformation and the principle of the diverse hardware environment. However the target population for the consolidation of the compatible central expression necessitates that urgent consideration should be applied to what is beginning to be termed the “ad-hoc inductive projection”. Based on integral subsystems, examination of inclusive instances provides a harmonic integration with the social dichotomy. This should be considered in the light of the functional baseline.’

We chose this as a programming example because it is so simple, and because it demonstrates that the best way to produce language automata is to mimic the way we construct language. It displays a simple and valid use of recursion. Above all, it is fun to use. Obviously, the serious user will bring his own word and phrase-banks to bear on it.

I put the Generator in the Public Domain and it was certainly the first of such programs to be so placed. Originally, it was written for a primitive C compiler to run on CP/M. From these humble beginnings, the program has taken on a life of its own, and is irrepressibly popular, unlike the vast majority of the code we write.

It has been used, developed and exploited by two generations of IT people and has been translated into a variety of other languages. Phil, who has since been a great fan of this type of programming, has published a variant in SQL on Simple-Talk, called ‘The Excuse Generator’. There is also a PHP version that I wrote to test out CSS Stylesheets. The output is in strict ‘core’ HTML, and it is handy for checking that Stylesheets work with unpredictable sizes of text. You can get it here and I explain how to use it here.

The Generator has been used in numerous, serious development projects. For a long time, BT at Martlesham Heath, UK, used the Waffle Generator to test comms lines. However, we’ve also had ‘thank you’ letters from desperate PhD students who bulked up their Thesis with this handy tool.

The singular peak of achievement was when the output of the Waffle Generator was submitted by a prankster to the Journal of Theoretical Psycholinguistics, was praised by two independent referees and published. I still have the article. As a tribute, some phrases from this exercise are enshrined in the Generator’s word-bank.

The Waffle Generator Source

The program itself is very simple. Following is the basic C# code, which could slot straight into any C# application. Here, we sticking to the simplest approach of using static wordbanks But I once did a VB version, with a built-in Text editor with word-banks that could be read in and customized for writing school reports, academic essays, and thank-you letters.

Unfortunately the source of the C# version is a bit too long for the body of the article but there is an HTML version here and a text version here.  The latest version is now on Codeplex with the other custom generators for SQL Data Generator  on Red Gate SQL Data Generator Community Generators

Using the Waffle Generator with SQL Data Generator

There was a time that one would need to hack together a user-interface. No longer, as we can now make it into a Generator for SQL Data Generator. As this is in Beta form, you will have to roll up your sleeves and build the DLL from the source code. (the DLL is version-specific)

Firstly, we’ll need the  SQL Data Generator. Don’t worry, you can download it for fifteen days free.

To do this generator we create a Class Library .NET Project. (Visual Studio Express edition will work fine and is free) We must add references to RedGate­.SQLDataGenerator­.Engine and RedGate­.SQLCompare.­Engine.

Firstly, we create the basic functionality. (see the C# code above) Then we create a public class that inherits the GeneratorBase, add the class attributes and Implement the constructor.

We create a file called WaffleGenerator.CS (we also provide the source to this as an attachment to the article). You’ll see that you provide, as attributes to the generator class, a category, a name and a description for the generator. You can then provide clues for the search of a data type. Here we say that the string ‘HTML’ or ‘Text’ in a column name gives the Waffle generator a score of 10. This means that the Waffle generator would be likely to be selected automatically for a column like ‘ArticleHTML’. You can change this to your own taste. We then provide the parameters with their defaults, to be included in the SQL Data Generator form.

When the SQL Data Generator starts-up, it scans a directory (normally the ‘generators’ subdirectory, for DLLs. Each of these DLLs in turn is loaded up and reflection is used to see if any public classes implement these interfaces. If this is the case then they are accessible to the application as ‘custom generators’.

This means that you can, if you are brave, you can configure the project so that the output DLL is written to (normally) %Program Files%­\Red Gate­\SQL Data Generator 1­\Generators­\ . If cautious, you can wait until a DLL is built, and then you can merely ‘release it’ by copying it directly into the SQL Data Generator’s Generator subdirectory, as follows:

465-WAFFLE4.jpg

When you subsequently start up the SQL Data Generator,  you will find that the custom generator is now listed alongside the others. If you use Beta 2, then you will have to rename the Waffle Generator to something else. All other Beta versions should work fine.

465-waffle1.jpg

You’ll see that it has picked up the name and description. This all comes from our “IGenerator” Interface

465-waffle2.jpg

Then, you just enable data generation for a text column in a suitable table and out comes plausible text by the yard. Just to test it out, create a table as follows:

CREATE TABLE [dbo].[waffle](
   [Waffle_ID] [int] IDENTITY(1,1) NOT NULL,
   [Waffle] [varchar](MAX) NOT NULL
) ON [PRIMARY]

You will find that suddenly you have as much text as you can cope with, ready for you to try out that wonderful RegEx or indexing algorithm.

465-waffle3.jpg

So, based on this example, why not write an excuse generator for an IT operational failure, based on Simon Travaglia’s excellent word-bank.

…or more to the point, when you’re testing your database-driven application, you can refine the plausibility of your spoof data to the point where you never have to look longingly at your live system, replete with all its confidential, financial and commercial information. Demos and presentations will never be the same again.

Load comments

About the author

Andrew Clarke

See Profile

Andrew Clarke has been developing software applications for over 35 years. He is a database expert, but also has had many years of experience in designing and programming applications and software tools. He has a particular interest in website-publishing and ECommerce. Before joining Redgate, he worked with the first two winners of the 'Apprentice' program at Amstrad, creating various business applications, He is the editor of Simple-Talk.

Andrew Clarke's contributions