On 21-09-15 02:46, Peter Uhnák wrote:
So far so simple... however what I don't understand:
1. What if I want to have different descriptions for the same attribute? For example in some views the email is required and in others it is not.
asMagritteMorph is just the quick and dirty variant for straightforward situations.
2. Must the description be part of the object?
Yes. Single responsibility principle applied.
Maybe I am still not fully committed to the having massive protocols with tons of extension methods instead of externalizing the code to separate adapters and whatnot.
Ahum, that is exactly what Magritte does, while reusing the smalltalk tools. For very large domain models (more than several hundred domain classes), you'll be able to do better using a dynamic object model, and then you'll have to develop browsers, editors and inspectors for that.
3. What if I want only partial rendering? For example in one view I want to be able to edit only name and age, and in another one all three. Since #asMagritteMorph collects everything I don't see how I can customize this.
asMagritteMorph provides the default. On Object it is defined as Object>>asMagritteMorph self magritteDescription asMorphOn: self Object>>magritteDescription ^ self basicMagritteDescription Object>>basicMagritteDescription ^ MAPragmaBuilder for: self which collects all descriptions and puts them in the container described by Object>descriptionContainer "Return the default description container." <magritteContainer> ^ MAPriorityContainer new label: self class label; yourself. The nice thing about a MA(Priority)Container is that it supports a large part of the collection protocol, so you can just do Person>>asNameMagritteMorph ^(self magritteDescription select: [:each | each label = 'Name']) asMorphOn: self So you'd define all possible descriptions you want on the domain object itself, possibly using extension methods, and override #asMagritteMorph to only return the default descriptions. For complex dependencies with extensions, use a smarter MAPragmaBuilder subclass that makes decisions based on which extensions are loaded. You also want to take a look at reference. In the Seaside generation that is used like MAInternalEditorComponent>>buildComponent ^ self value isNil ifFalse: [ (self magritteDescription reference asComponentOn: self value) setParent: self; yourself ] so that provides an extension point for nested objects. I don't see it used in Magritte-Morph
Also, is there maintained Magritte-Spec? I've seen something by Sean, but it's from 2013 with a single-ish commit.
I don't know if it needs more. Nothing changed in the spec interface since then, did there? Stephan