[Seaside-dev] Seeking comments on small (?) change to WAComponent

James Foster Smalltalk at JGFoster.net
Thu Feb 5 17:12:48 UTC 2009


I find that in an attempt to follow the Smalltalk practice of small  
methods in my Seaside applications I end up with a number of render  
methods that are each passed a WARenderCanvas. I find it awkward to  
keep repeating '...On: html' and have found it handy to create a new  
abstract subclass of WAComponent that acts as a superclass for my  
components that has an instance variable, canvas, and two methods:

renderContentOn: html

	canvas := html.
	self renderContent.
	canvas := nil.		"to allow GC"

renderContent
	"Override this method instead of #renderContentOn: and draw on canvas"

Note that this is fully backwards-compatible and should not impact any  
existing code that implements #renderContentOn: (though one could  
choose a different name for the instance variable if needed to avoid  
conflicts with method arguments and temps).

This approach makes my code less cluttered and (to me) more readable.  
I'm not asking the community to change for my convenience, but I'm  
asking for general reaction for my own education. And, of course, if  
others see some value in this and are willing to incorporate it into  
the framework, I'd be delighted.

James Foster


More information about the seaside-dev mailing list