Recently there was a question about Magritte extensions on the Pharo users list. It has been a while that I was really involved in developing on (QC)Magritte and doing stuff on the web, but on my todo list, there is feeding back the improvements on Magritte I have made for QCMagritte to Magritte itself. And while doing so, adding tests and cleaning up code where needed.
The first extension I would like to feed back into Magritte is the Builder.
The background of the builder is the following:
- Having a custom component set, and wanting to use this custom component set can be very tiresome for larger applications, because you have to set a component class for all descriptions.
- Also it breaks the layering Magritte is trying to build in, as you need to "pollute" your model descriptions, with all kind of stuff, that determine how everything looks like. With stuff that belongs in your UI code instead of your model code.
I believe that the builder is a solution for this problem. The actual builder can be injected as an extension (for an example see the QCMagritte demo) and processes all descriptions. As it is a visitor, it can replace or enrich your descriptions with whatever you need in your UI based on the type of description.
The builder affects the way the Magritte description is created, so the package contains an override of magritteDescription. If I would implement this on Object (the most logical point), I would need to put the builder into Magritte-Model. Having no builders, this would of course not affect the returned description. Does anyone object to putting this here? And if you have objections, do you have a suggestion to do this elsewhere?
There are 4 different type of builders I have made so far:
1. one for multi language support. Replacing all strings with dynamic strings.
This is included in the multi language package of QC Magritte (QCDescriptionBuildMultiLanguage)
- one for security, filtering the descriptions on things the user is not allowed to see, or making things the user is not allowed to change readonly. (QCDescriptionFilterForSecurity)
- one for support of “expanding” a description. When I have a user with an address, I want to see the properties of the address directly, without the need of opening the address seperately. (MADescriptionFlattener)
- several variants for the look and feel, inserting the components corresponding to the theme.
An example is included in the QC Magritte build: the tutorial makes use of a builder that sets the components to the look and feel of Bootstrap. (QCBootstrapComponentBuilder)