[Seaside] Re: Seaside best practices

Stephan Eggermont stephan at stack.nl
Tue Feb 12 14:14:09 UTC 2013


(Stephan: I've asked Diego for some comments too. Here is the first part)

Lately I have worked with Magritte, and being one of the authors of Deltawerken, I probably should make a mail about the advantages and disadvantages of both libraries.

Magritte is a library that is really good in describing  an object. You can see it is created from a theoretical perspective, with a consistent and systematic way of implementing all functionality.

However this creates at some points difficult indirections. These indirections make the code (at some points) hard to understand. A good example is the code I added for my project to the root object:
descriptionContainer: aContainer
	<magritteContainer>
	^ aContainer
		componentRenderer: QCFormRenderer;
		stringWriter: QCLabelWriter;
		yourself
This code is of course very compact, and for those proficient with Magritte, this code may be understandably. But most people will be confused by this code. Some explanation for those who want to follow:
	> it is intended to render the form in the way I want, with the styles I want. This means that I render divs instead of a table and have a different "toString" method when an object of mine is converted to a String.
	> This method is executed by the pragmabuilder, that builds the description. It sets 2 properties to the container, that override the default values for the container description. When rendering it asks for a component renderer to render the component, and thus will use the QCFormRenderer to do so. When asked to convert to string, it will use the stringWriter to do this.

Also a lot of features are implemented using "monkey patching". The most known is the asComponent, that is implemented in Object.
Personally I am not a fan of monkey patching, but using Magritte will force you into monkey patching the Magritte classes. You will need custom properties, if you want to do some more advanced stuff with Magritte. Inheriting is not really recommended, as you will need to inherit from all types to do so.




More information about the seaside mailing list