the world of model driven development

Archive for the ‘review’ Category

Get Create – A solution to the dilemma of using Entities in quantum states.

A common problem I come across in developing Mendix applications is when I have to manipulate an entity in a microflow which may or may not exist. This quantum  occurance would occur when having to update an entity from a 1-1 relationship, or on a 1-* where the child entity (on the many relationship side of things) is also related to a secondary attribute, such as a day or version.

When dealing with this situation you have to try retrieve the entity using the relationship or Key Attribute(such as date), check if it exists, if it doesn’t  create the entity with the new Key Attributes. This now leaves us with two  entities which have to be manipulated seperately or reretrieve the entity into  a common name.

Going with the first case lets look at what my first pass solution would look like on the following Module:

As can be followed from the above microflow there will be much duplication of logic, and complication of the microflow at quick inspection.

Note: When checking to see whether an entity I retrieved exists I like to create an exclusive split with the caption ‘Exists?’ and the formula ‘not($Entity=empty)’. This keeps the reading of the flow in the positive light rather than negative.

The solution I follow now as my standard practice in these circumstances is to create a microflow called Entity_GetCreate which will handle this retrieve or create logic for me and return the respective entity so that I dont need to concern myself with handling these cases seperately.

This GetCreate microflow for the above entity would look as follows:

Which results in the original microflow being simplified to:

Much easier to read for business and mendix users.

Format String – Widget spotlight

There are a lot of widgets available in the Mendix Apps- & Add-on Store. Basic display widgets are sufficient for building forms, but sometimes you need a little more kick than what you get from the out-of-the-box widgets. For instance dynamic labels. Creating your own widget is an option, but don’t reinvent the wheel when someone already has, which you’ll find out when you visit the store.

I found Format string and it has some nifty applications. Think of it as an “über-label”, giving your Crud applications a little bit more character in terms of dynamic display. Its handy for dynamic label messages or basic reporting, by allowing you to format a string; very much in the same way we do logging-style messages in Mendix apps. You do this by setting a format string and replacement parameters.

Here is an example. I have a customer as an entity on my form. Instead of displaying a read-only Name and Surname Text box, you simply add the label and use the token place-holders:

Under Data source in the property panel, you select your attributes:

You could also have the ability to format dates and the option of rendering this as a div or an input. With a style formatting you’ll have a perfect header for your report or section in your form.

The result:

I’ve look for something like this for a while now, and this is perfect. It does exactly what I want when displaying dynamic labels.

Design a site like this with WordPress.com
Get started