Lollisoft
Lollis Software Blog - Von der Idee schnell zur Software

At this weekend I started creating a new feature in my code generator targeting DevExpress. While watching a tutorial video about creating reports I followed it by creating my own version of such a report. I required a little bit more time, but at the end I’ll be faster after the first step. I have a code generator doing the stuff automatically what was done by hand in the tutorial. That way I am able to create much more reports in a blazing fast way.

Here is a sample of the CDKatalog model I demonstrated with some YouTube videos:

CDKatalog-Grid-With-Report

This picture shows both, the grid and a ready made report

Of course, there is a direct relation between a UML class such as Musiker, but it was a first trial to get a report generated out of an UML model. It also shows that I have the option to create master detail reports with ease (as an end user!) and thus the prototype could now be used to manage simple data structures including creating various reports of it.

Hi, after my last post in german I will write a followup in english. My work is progressing. I wrote about generating a CRUD application based on the SCSF application block using DevExpress and DevExpress extensions for SCSF. The first bunch of work was to get the sample BankTeller Applicartion into a XSLT template. Some parts were simply copied and templatized without really generating the code by model definitions. Other parts as of the form fields were generated by the model after all. The second step was to add CRUD elements like the navigation (add, delete and save buttons). Then I added stuff like switching between a fixed form, a runtime designable form and least a grid per entity or UML class. Referring links of mentioned products, projects and the like are placed in my last post.

Here it is what I got after several hours of work:

BanktellerRippedOffForCRUD

Layout form capable of runtime layout (end user)

Here is a screenshot with another skin and showing the grid variant with the builtin features from DevExpress (grouping):

CRUD application showing DevExpress builtin features

CRUD application showing DevExpress builtin grouping feature

And here is the navigation area of the ribbon:

BanktellerRippedOffForCRUD_2

Icons for navigation, add, delete, save and view modes (grid, layout, simple)

Another sample is showing the application form as of the first picture running as a prototype in wxWrapper:

wxWrapper based prototye on Mac OS X

The wxWrapper based runtime prototype

Codegenerierung kann auch schönes vollbringen – zumindest oberflächlich. Nun habe ich einen brauchbaren ersten Wurf eines Codegenerators erstellt, der unter Verwendung des SCSF in Verbindung mit DevExpress einen schönen Prototypen erstellen kann.

Die Oberfläche ist eine Ribbon Forms Anwendung, welche einige Module enthält. Im ersten Moment war mir wichtig, eine einfache Modellierung zu ermöglichen und auf einer bestehenden Demonstrationsanwendung aufzubauen. Die Demonstration hat Ihren Ursprung in CabDevexpress. Der Author hat bei diesem Projekt gute Vorarbeit geleistet (DevLynx).

Folgendes UML Model habe ich aus der Demo abgeleitet um dieses dann bis zu dem unten gezeigten Stand zu bringen (generieren):

UML Diagramm zu CabDevexpress

UML Diagramm zu CabDevexpress

Dieses Model enthält ein paar Besonderheiten. Die Stereotypen header_group und detail_group bestimmen, wo in der Anwendung diese Felder angezeigt werden sollen. Damit erreiche ich, in welchem SmartPart die Felder erscheinen. Der Codegenerator kennt momentan nur diese beiden Gruppennamen abgebildet als Stereotypen.

Die visible Felder werden momentan ignoriert, da ich die Informationen, die an verschiedenen Stellen in der Anwendung gezeigt werden, anders generiert werden.

BankTellerDevexpressSCSF

Eine schöne GUI macht viel her

Hier ist nun einiges zu berichten:

Auf der linken Seite ist die eingehende Queue zu sehen. Ihre Daten bekommt Sie von einer Mock Datenquelle. Die Methode ist im UML Model mit einem Stereotyp queued versehen um dies zu erreichen. Bis jetzt werden alle Klassen auch als Queue Quellen generiert. Dies ist noch anzupassen um nur solche Klassen mit einem Queue Mechanismus zu versehen, die eine Methode mit dem Stereotyp queued haben. Angemerkt sei hierbei die freie Wahl der Stereotypen, denn erst im Codegenerator wirkt sich etwas aus, wenn man diese Stereotypn verwendet. (Ausnahme = visible, welches im Runtime Prototyping Verwendung findet)

Der obere Bereich der Maske (Customer ID, FirstName, LastName und CustomerNumber) ist ein normales (nicht veränderbares) Layout.

Der untere Bereich ist veränderbar und kann somit in der Prototyping Phase herangezogen werden, um ein nachträgliches ’schönschubsen’ zu realisieren. Die gespeicherten XML Daten können dann in die Entwicklung zurückfließen, damit das Layout übernommen werden kann.

Eine weitere Funktionalität ist das Deployment in Visual Studio. Hier habe ich versucht, automatisch auch diese Einstellungen in das Projekt hinein zu generieren. Es klappt wunderbar. Neue Modellelemente (Attribute in der UML Klasse) können leicht dazumodelliert werden. Einmal generieren, kompilieren und Installer bauen. Schon geht es ab mit ClickOnce in das Deployment Verzeichnis. Die nun fehlenden Felder können einfach über den Designer hinzugefügt werden.

All diese Fähigkeiten von DevExpress in Verbindung mit SCSF und CabDevexpress sind eine gute Grundlage, um eine Entwicklung schneller und näher am Kunden zu realisieren.

Nähere Informationen zur Arbeit am Generator erfragen Sie bitte im Kontaktformular.

Euer Lolli.

Smart Client Software Factory generated with help of my tool and a XSLT template

Smart Client Software Factory generated with help of my tool and a XSLT template

I have evaluated the Smart Client Software Factory patterns & practices for Visual Studio 2008 and decided to begin a template to let it generate a full appliaction using the SCSF libraries. After some days reading, buying books and playing around with the guidance and samples, I started to create my XSLT template helping me to create as much as I can create. After four days of work I was surprised how easy it is to create a template for this library and I was ready to run the generated application.

In the background you will see the wxWrapper application running the prototype of the lbDMF Manager UML model. Using this prototype I created the application in front that actually has a very different layout and usability. (Except the very simple button list for the forms)

The result currently contains a mock for the data (three entries per entity), but it will be straight forward to add more templates to create a database backend entity model (maybe NHibernate or even other stuff). You only need to change the entity classes to be real database entities to any data source.

I think that this shows the full power of the XML and XSLT approach that I have choosen. Even others (and even I) use T4 templates, for sample, it will be generated nearly the same amount of code. I will publish this template in my project some days later. Contact me please if you are interested in participating to template development.

Today (4th Jul 2011) I have made the template publicy available in my CVS repository. Feel free to try it out. It works even with Sharp Develop 4.0.

Simple sample of how to use UML Activity diagrams to generate code

Simple sample of how to use UML Activity diagrams to generate code

Now I have done the rewriting to get a more flexible code generator. In my last post I have listed up some points I may have to do to enable this new feature in my next release.

I’ll shortly describe the activity:

1.) Using send signal action to trigger an existing event handler.

The new feature is possible because I have used the send signal action to trigger an existing event handler that is responsible to create a XML model in memory (into a variable named memorybuffer).

2.) Use another handler to write te buffer to a file.

I am using a file at the end, thus I store the memory buffer into a specific file named ‘lala.xml’. I’ll do the naming in the activity transformation. It is also possible to use the memorybuffer variable directly, but I have choosen to demonstrate using a two step file creation.

3.) Using another signal handler to trigger the actual XSLT transformation.

The XSLT transformation handler is a result of a separate handler I have created because my existing one does all the steps in one code function including asking for the XSLT template. The XSLT template is passed as a parameter in the signal activity step within another special parameter. The file is passed indirectly by using another variable within brackets source = {file}. These indirect usage is also applied in the parameters of step 2.

Conclusion

The sample demonstrates the ability to use predefined small activity steps (event handler spread around in my code). These includes making decisions, showing message boxes, writing a variable to a file, reading from a file into a variable. Short: All my event handlers can be used via the send signal activity step.

I hope that the possibilities are clear and you will find these new features useful.

Ersetzen von Address Angaben in Dateien ist aufwändig. Eigentlich können das auch gute Editoren. Hat man aber gerade keinen zur Hand, hilft auch folgendes Script:

#!/bin/sh

mv $1 $1temp
sed ’s/Von Straße 5/Zu Straße 6/g’ $1temp > $1
mv $1 $1temp
sed ’s/PLZ Ort/12345 Lala/g’ $1temp > $1
rm $1temp
# Script Ende

find . -name “*.cpp” -exec ~/bin/replace-address.sh {} \;

Music for lau, but you can donate

Dezember 31st, 2010

Twitter is a good place where you could randomly get new stuff. Today I got a new tweet that shows up a band doing it in a different way. You can download the music but may donate as you like. I find this a very good direction to, a) directly support the band and not other in between and b) you can decide how much. And I have donated :-)

http://www.severedfifth.com/

I would like to know about more such bands :-)

Hi,

Currently I am developing new activity steps to enable a more flexible code generator. Practically it is a code generator workflow. My old code generator is an activity step and does the stuff at one step. That steps in the code are as follows:

  • 1.) Get the identifier for the current application (by the value given as parameter ’source value’)
  • 2.) Save the current working directory
  • 3.) Get values ‘UMLImportDBName’, ‘UMLImportDBUser’ and ‘UMLImportDBPass’ from the active document (that by the active application). These are modifiable and stored by the properties of the application.
  • 4.) Save the current mode (database / local document file) and switch to database to export actual contents.
  • 5.) Reload the application model from database into the internal object model and set back the original mode.
  • 6.) Retrieve the application identifier from the applications model by it’s application name ’source value’ of the action and store it in a local variable.
  • 7.) Get the value of the XSLT directory where the action has to be performed ‘codegenbasedir’. Do this optionally by direct database read if it is not in the list of application parameters.
  • 8.) Put the identifier as a variable in the active document ‘SaveApplicationID’.
  • 9.) Call a registered event handler by it’s name ‘exportApplicationToXMLBuffer’
  • 10.) Get the result ‘memorybuffer’ that the handler has stored in the input parameter container (not the result container).
  • 11.) Also get the file name the handler has stored ‘filename’.
  • 12.) Change to the working directory the XSLT transformation should perform ‘codegenbasedir’.
  • 13.) Perform the XSLT transformation and save the result to stdout.

The enumeration doesn’t work :-)

You can spot the point of inflexibility as it is clear. The function does too much and expects the XSLT transformation generates files. The activity step cannot be used to cascade several code generators to enable M2M transformations. And extending the existing one is the wrong way, because it will become a monster and keep being not flexible.

It would be much more flexible if I split the steps and use them to model the code generator workflow in an UML Activity diagram. I have demonstrated workflow activities earlier by enabling validation in business forms (more in PDF version chapter ‘Applying business rules’ – sorry for the typo). That is, I enable modeling of validation rules rather than coding them. With a short view about that, it is much more work to ‘code’ in UML Activity diagrams, but at a longer and deeper view it raises the abstraction level and with a M2M transformation it will also ease the modeling.

That is exactly the cause I start writing new activity steps that could be used in an activity or to name it also workflow.

One action of the above steps would be getting the identifier from the current row in the database form. But it is more difficult than you may expect. It is the complexity of the SQL query I rely on. What I need is to get the primary key column out of the current query object that represents the value I match against ’source value’ – and it’s ’source column’. In my actual scope it is the application name to generate code for and it is not declared as an unique column.

A simple solution would be to make that column unique and complain if it is not. That would make the workflow more easy. That solved, I ask my self about the place where I implement the stuff to get that identifier.

So currently I think about extensions of my database classes to ease the modification of a given SQL query. But how to start and what solutions may be the best. When the database query is simple, I may choose simple string splitting to get the columns and then add new columns for sample. But what happens if the given query contains sub queries or joins?

If the given column and value points to a detail table it still may not complain about not unique values. But rather it is a design error of the code generator workflow parameter passing definition (don’t think about wrong templates used yet).

It simply points to a detail value not one of the master values in a join. The transformation may work but also may not work by the given identifier. It is a scope problem and it is not strongly typed.

So if a form contains SQL joins and I use columns from the detail side (I think the right side in the join), then the scope problem arises. Thus I must not only test against uniqueness but also against the fact not using values from the detail side (tables referencing to master side – or the left).

Some of the resulting code – I hope doing it right – will be in database classes, but other stuff may rather be placed in a separate action step to enable designing validation against the intention of the workflow. An action step to retrieve the identifier therefore may not only return the value, but also return some more values, such as what primary key column was used and what table the column is from. Also it may return the primary table if a join or other circumstance results in a multi table query.

So you see it is not easy to write this action step and you also see, it is only the first step :-)

And I cannot expect too much in the scope. What is if one uses a ready made workflow at the wrong place and tries to pass a value he / she configures? I cannot expect an ‘application name’ and try to get the identifier from the application table. It will fail on forms. A good use case to start generating code at the scope of a form would be predesigning the form in a different format – like DialogBlocks. The workflow therefore may create a single form project in DialogBlocks, let the user design while waiting for the application and then reverse the design to gather probably new fields to be optionally added to the database model. That said, you not only change the scope where to start code generation, you also need more flexibility by waiting for an application and using a reverse engineering step to collect new fields and possibly also a new order or complete new design that must use a XML based form in the prototype to directly present the design.

What I can say, you will get plenty of ideas if you can simply do it. Also a code generator model / workflow is language and implementation neutral, thus you could probably design you own tool by supporting a suitable code generator converting the model into real code of your choice.

For any questions, please contact my via Twitter.

wxRibbon on Mac

wxRibbon on Mac

Here is a sample about my work on wxRibbon code on Mac OS X Snow Leopard.

The code actually compiles, but uses the MSW art provider that probably is the cause for the drawing failures.

But at all it looks good for a one day porting work. On Mac I use wxMac 2.8.10 and on Windows I use Open Watcom and wxMSW 2.8.5.

It would be fine, if there are some Mac OS X developers willing to help fixing these issues.

When the window is much bigger, then the visible icons, now showing disapear, thus the window size is that small.

Edit: The missing reference: The wxRibbon project was developed by Peter Cawley: http://www.corsix.org/gsoc/ribbon.html

Hi,

after posting a question, I got an answer to the enum issue. Michal Necasek wrote that enums have different sizes. Open Watcom uses the smaller 8bit and MINGW uses the 32bit size and thus when returning an enum from OW, MINGW gets undefined bits from bit 9 onwards.

His solution is as follows:

enum lbErrCodes {

ERR_NONE = 0,

ERR_FAIL = 1,

ERR_SOWISO = 2,

ERR_LAST = 0×7FFFFFF

};

Or one could use compiler settings to solve this issue.

That helped me to cope with my porting attempt :-)

Proudly powered by WordPress. Theme developed with WordPress Theme Generator.
Copyright © Lollis Software Blog. All rights reserved.