Part 1 - RAD and Custom Code Generation
I'm going to write a blog series about Rapid Application Development (RAD) and the advantages of using a custom code generator. Today I'm going to review what I'm going to cover in the coming weeks.
The most obvious question to ask on this topic is this: With all of Visual Studio's drag-and-drop development ability isn't it pointless to develop a custom code generator to begin with? The answer to that question really lies in understanding the difference between developing a working application and developing a production application.
A consultant's job isn't just developing an application that satisfies a client's requirements within a given time and budget (a working application), but in also leaving behind a code base that can be enhanced and extended with just a modicum of effort (a production application). There should be at the very least some basic documentation and the concept of an n-tiered architecture, with each tier easily distinguished from another. Good consultants don't just develop for their client, they also develop for the next developer -- who may very well be themselves if they capture more of the client's business.
Microsoft's RAD tools offer a good number of positives. The Enterprise Libraries, for instance, give current best practices with good examples and documentation. They are easy to add as references in an application and easy to use out of the box. The biggest disadvantage to the Enterprise libraries are that as best practices evolve the library used earlier may be obsolete, so a very necessary first step is to wrap all of the libraries you intend to use into an assembly of your own. This way you can guarantee the interface and change the implementation details as newer methodologies and best practices appear.
Without subclassing in this way upgrades to the libraries may require wholesale updates in your application to keep it current. This isn't just theoretical pondering, the move from the .NET 1.1 framework to the 2.0 framework incorporated the Cryptography and Membership libraries into actual framework namespaces, without having the libraries wrapped switching to the newer (and better) implementations in the framework proved to be very, very painful.
Another problem with using the libraries is that you are stuck with what you get - which in some cases may be more than you really need. This is also the case for many of the drag-and-drop techniques used in Visual Studio - you tend to get everything whether you need it or not. It tends to be hard to read and harder to update and support.
A custom code generator avoids many of these aggravations. You can develop in the way you typically develop. You can implement automatic documenting to a large degree. You can get most of the rapid development pluses (i.e. get up and running fast) with few of the minuses (lack of supportability). You can design it to end up with a readable, easy-to-support and enhance code base.
To do this we'll need to tackle the following areas, which we'll do over the coming weeks.
-
Seperate the UI from the Business implmentation, but decide what type of UI we want to use so that we can develop a concrete example. (I'll use a WinForm)
- Be able to modify the app.config file from within the application
-
Load and save definition files so we only have to define our objects once
Use SQL SMO to do the following:
-
Define a table and have it created in the selected database
-
Create table DDL and persist it to a directory for backup into a code library
-
Create the formatted T-SQL for the CRUD stored procedures based on the definition file
-
Execute formatted T-SQL to create the CRUD stored procedures in the selected database
-
Create integrated InterfaceObject, DataAccess and ApplicationObject (BusinessObject) based on the defintiion file
-
Create a simple application using the code generator to show it in action
-
Define the application so the steps will relate to a concrete implementation instead of an abstract idea
-
Calorie counter (perfect to help with my New Year's resolution)
-
Create a list of features that we'd like to see implemented for future versions