I love creating tools that simplify a developers life and can save time.

My intent with the next few blog entries will be to publicly step through the process of designing, creating, and using tools that I have named the "Fast and Filthy Add Ins for Visual Studio."

"Fast and Filthy" is a play on the term "Quick and Dirty." These add ins will be Visual Studio add ins that will give a developer a fast and simple way to create prototypes for customers/management. I think this also has the potential for use by managers and even clients (more on this later).

Taking Advantage of the Hierarchical

Classes, controls, and data tend to be hierarchical in nature. Classes have properties and methods (which have parameters and a return value ). Controls contain collections of controls. Data tends to be hierarchical to some degree - Databases contains tables which can be related to other tables, tables contain fields, etc.. And then of course there's XML: hierarchical-incarnate. You get the point.

Visual Studio and the .NET framework have proven that this information (as well as everything from project files to type libraries to comments) can be represented in a single flexible format: XML. Designing in XML, though, can be a bit tedious. For example, I love the power that XAML provides, but XAML has not made coding quicker or easier in my opinion.

I think that it is possible to express classes, controls, etc in a simple, text-based, non-graphical (and for that matter language agnostic) way. Basically, take the contents of a textbox and apply some fairly simple rules to create/convert into the desired outcome.

The TreeView For Example

The simplest and most direct example of this would be treeview control. If you've ever manually filled a treeview control, you know what I mean. If you take the graphical approach, you are living in the collecti0n/TreeNode UIEditor scrolling through mini property windows:

image

If you take the programmatic approach, you are building and connecting parent and child nodes:

   
Dim parentNode As TreeNode
Dim childNode As TreeNode

parentNode = TreeView1.Nodes.Add("Node0")
childNode = New TreeNode("Node2")

parentNode.Nodes.Add(childNode)

parentNode = TreeView1.Nodes.Add("Node1")
childNode = New TreeNode("Node3")

parentNode = childNode
childNode = New TreeNode("Node4")
parentNode.Nodes.Add(childNode)


Consider this for a moment: a textbox with AllowTabs set to True (so that tab characters can be typed within the text box). You type the following into the textbox:



Node0
Node2
Node1
Node3
Node4


This text can easily be parsed to create a treeview. Furthermore, you can move nodes around much easier in the text box. For example, if I wanted to make Node4 the child of Node2, then I can cut the Node4 line, and then paste it under Node2:



Node0
Node2
Node4
Node1
Node3


Much easier than changing it through the designers or code.



You might say that with this method you lose some of the finer control (icons, bolding, etc) of the nodes. I agree, but you could add some new rules to the parsing. For example, to use the first few characters of the text to influence rendering:



(0)Node0
(1)Node2
(2)Node4
^(0)Node1
^(1)Node3


"^" could mean the node is a checkbox node, and a number in parens could the imagelist index of the image to use on the node.



You are essentially "drawing" a treeview with simple text.



The DataSet



Consider the following text for generating a dataset:



Customer
*Customer_ID
sName
bIsActive
Orders
*Orders_ID
@Customer_ID
dOrderDate
dShipDate
Customer->Orders


This text could:




  • Create a DataSet


  • Add a DataTable named Customer


  • Add an integer column named Customer_ID to the Customer table, and make it the primary key


  • Add a string column named Name to the Customer table


  • Add a boolean column named IsActive to the Customer table


  • Add a DataTable named Orders


  • Add an integer column named Orders_ID to the Orders table, and make it the primary key


  • Add an integer column named Customer_ID to the Orders table and make it a foreign key


  • Add a date column named OrderDate to the Orders table


  • Add a date column named ShipDate to the Orders table


  • Create a relation between the Customer and Orders table, no need to specify the columns, it knows because it knows whether columns are primary or foreign keys



Pretty cool, huh?



Now lets take this one step further - the same text for the dataset could be used to generate TSQL to create the structure in a SQL Server database! If you hang on to the text (embed it in a comment for example) you can keep the dataset and database in sync.



Classes Too



Heck, if you think about it - the same text used in the Dataset example could be used to generate classes with properties and collections (Customer could have a List(Of Orders) due to the Customer->Orders line). All that's missing is methods, which could easily be created by putting parens at the end of the text (e.g. Execute() )



One More Thing



Earlier I mentioned that these add-ins could be used by management or clients.



I see the the text blocks as a short hand for creating prototype GUIs and data. They can create their own prototypes (with a little training). Maybe even compile the prototype into an executable that could be distributed to people. A "managers tool" could be created as a VS Package IDE so that managers would not need to have Visual Studio installed.



Analysts could open the package and design the prototype right in the meeting as people are talking about it. A great way to build a concencus in my opinion.



They can then approach the developer with the prototype, and demo what they would like to see. I think that is a much easier approach than having the someone try to describe an interface in a specification. Or it could provide them with screen shots that become part of the specification. I'm not saying that managers/clients are the best designers, but I think giving them such a tool would empower them.



At least they can generate talking points, and with a little tweaking serve as system documentation.



Stay Tuned...



Next I will be talking about ideas on how to implement these features. And once the code becomes more solid, I will put it up on Codeplex.



This is a work in progress, and I would appreciate any comments on the the ideas presented here (positive and negative). It can only serve to improve the final output.



Take Care!

Comments

John Suder said…
The central concept seems to be that information can be represented in a terse "business essential" format that can be transformed into different manifestations (code, sql schema and access, user interface). This is at the heart of the DRY principle (Do not Repeat Yourself). If you haven't already done so I'd recommend looking at what Ruby on Rails has done with scaffolding and the steps the framework takes to minimize repetition of facts.

I've also wanted to reproduce the time saving nature of the RoR tools in .NET. I know there are attempts currently in the works but like everyone else in the world I'd like to re-invent the wheel because I secretly believe that my wheel would be better (did I just write that out loud?).

Popular posts from this blog

Using Linq To XML to Parse XML with Multiple Namespaces

String Interpolation in Powershell Strings