We all do it. We all feel guilty about it later. We all pretend to not see it when we see presenters do it live or when it's done in a video.
It's demo data. Useless, often completely random, sometimes requiring a disclaimer that it isn't based on real life so that nobody gets offended or calls the lawyers. But we're surrounded by demo data, or testing data, or "I just wanted to see what the component looks like" data and if you are reading this article you are probably guilty too. Don't worry, nobody minds the ten minutes it takes sometimes to write up a quick class and generator for some data. There isn't some great anti-achievement clock running to record every time us developers spend some time lining up a few ducks so we can properly see what a view looks like with data. And if there was, we'd all be in trouble.
Components like the RadGridView (any .Net flavor) don't just offer standard grid-y things like sorting, filtering, and grouping, but also a fast and responsive data engine with cool bells and whistles like multi-cell selection, a variety of exports, and interoperability with other components in the suite and platform.
However, now that you've got your Grid component working, you need some data to display. Since the senior devs get upset when you start grabbing data from random sources around the office (guilty as charged :D), you decide to write up a few quick classes to display "remote data".
~10 minutes later you've got a class and a quick generator to populate out a list, it's tied to RadGridView, and you've got a functional control to bring to the powers that be to show off the wisdom they made in purchasing a Telerik UI suite. The demo goes so well that there are questions -
"Can it display hierarchical data?" - Well yes, but the class isn't set up to be hierarchical. Give me a few minutes to get that setup...
"Are there charts? We need financial charts!" - Sure, I haven't looked at them, once I make that class hierarchical I'll work up some financial data as well...
"Excellent, you'll be ready just in time for your review!" - Review?! But I've got a ton of demo data to write up!
You can see where this is headed.
Nobody wants to rush through getting demo data ready for a new component suite when the powers that be are sitting around waiting for your demo so they can finish your review. That's pressure!
Understanding this is a daily risk developers have to deal with, I'd like to introduce a small side-project to help users with Telerik .Net components either get off the ground or whip up a quick view to test a control. The Telerik.UI.Net.DemoLibrary project is live and public on Github as I write this and was also used (but not highlighted) in our previous post about .NET - The Bad Parts.
Let's take a look inside to see what resources are available within the library. Assuming we're all familiar with Visual Studio, here's a class diagram of the classes contained in the .01 Alpha version:
Each of these class types has a generator for creating either individual items of a given class or a List<T> of the class. If we go straight to Solution Explorer we can see what some of the Generators look like:
Neat, right? As you can see the alpha tag applies since some generators have optional parameters and some require a concrete parameter. Over time I plan to iron out these rough edges, but I wanted to first get a sense about which would be more useful for developers. Since it's on Github, however, feel free to recompile with any tweaks or changes locally, or provide me with feedback and I can look to include it in library updates.
Since we had some code-reuse issues within code generation, there are also some auxiliary utilities which made sense being public. You can find these within the Static folder:
So in case you need a quick list of names, countries, cities, books, or want either a random length string (TextGenerator.GetRandomLengthText) or a random sentence (.GetRandomText()) you're covered. Need an email? Use .GetEmail() to produce a name from the names list '@fakegmail.com' email address so it will pass email validation. TextGenerator may get split from a TextSource and move to the Generators folder, but again, alpha version and feedback is welcome.
At the end of the day this won't generate the same type of buzz as a new product release, but if you're a developer like the rest of us, little utilities like these which save time and make the day a little easier are worth their weight in bytes. So head over to Github, grab a copy of the library, submit feedback on what you'd find useful, and have fun saving time while developing.
Evan Hutnick works as a Developer Evangelist for Telerik specializing in Silverlight and WPF in addition to being a Microsoft MVP for Silverlight. After years as a development enthusiast in .Net technologies, he has been able to excel in XAML development helping to provide samples and expertise in these cutting edge technologies. You can find him on Twitter @EvanHutnick.
Subscribe to be the first to get our expert-written articles and tutorials for developers!
All fields are required
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.