I'm currently reading a very good book. It the best I have read in months, probably the best computer book I read in 2004. The book, Software Factories, is a very comprehensive book. It is very substantial.
A big thing in that book is DSL:s (Domain Specific Languages). A DSL is in contrast to, for example, UML not a general propose language. One of the problems with languages that try to include everything is that it is harder for tools to translate the model into source code. Models used for computation must be more precise than UML could provide.
I'll try to give an example of this. This example is inspired from the book. DSL has been introduced as something that will come in the future. But if you write WinForms application with .NET you already use it today. Yes, the WinForm designer is a type of DSL language. The designer view is a tool that you use to draw the layout of the form. The source code is generated from this view. If you then make changes in the source code, the designer will be updated, synchronized, to reflect the changes that have been made. (This will happen almost immediately. It is not as good as the class design examples in Visual Studio 2005.)
With UML this synchronization should be almost impossible. With UML, if we are lucky, we could generate source code ones.
EXAMPLE
Here is a walk through that you could do to get a taste of DSL today. All you need is Visual Studio.NET.
1) Start by doing a new project. Create the project from a Window Application template. It doesn't matter if you use Visual Basic or C#. (But you can't use C++. The form designer for C++ will be included in the next version of Visual Studio.)
2) Go ahead and draw some controls on the form. When you have played with that for a while you could choose to see the code that has been generated. You do that by right-clicking on the form and choose "View Code".
3) The generated code will be hidden when you firsts open the code view. You have to click on the plus sign to the left of the text "Windows Form Designer generated code" to reveal the code.
4) Try to change something, for example the position of one control. This is done with the Location property. Switch back to the designer and the code change will be synchronized with this view.
5) Try to split the Visual Studio window in two panes so you see both the designer and the code at the same time. Change some more code. The form designer will not change immediately when the code changes. In the new class designer this will happens. Here, you have to click somewhere in the designer first.
Comments