class sugar: static inheritance

Kam Kasravi kamkasravi at yahoo.com
Wed Jun 8 16:20:17 PDT 2011



On Jun 8, 2011, at 12:57 PM, Bob Nystrom <rnystrom at google.com> wrote:.
> 
> Patterns like this have the advantage of supporting more than two interfaces. Where public/protected lets you define two windows, "to everyone" and "to my subclass", using composition to form those interfaces lets you define more fine-grained ones like "to the rendering system" or "to the UI layer".

Backbone and others equip objects with capabilities added at runtime. Effectively traits, they retrofit existing objects with new behaviors that can only be done in a dynamic language. Currently new methods added via extend cannot take advantage of any closure defined within the constructor, though it seems that private enables this. These 'dynamic' patterns are becoming more popular in recent frameworks. I think these types of patterns are important and they have no analogue within static languages. I thought Allen had a great summary of this 
http://www.mail-archive.com/es-discuss@mozilla.org/msg06566.html


> 
> - bob
> 
> 
> A concrete technique for this is the use of the template method pattern (for example, http://www.oodesign.com/template-method-pattern.html ) which is one of the GOOF patterns.  In this pattern, an abstract algorithm is represented as template method with explicit this method calls at each extension point.  Subclasses are expected to over-ride does methods as a means of configuring the abstract algorithm.
> 
> protected if implemented with a reasonable semantics is a way to support such reuse patterns.  For example, protected provides a way to formalize the subclass extensibility contract.  It is the protected methods that define that contract.  Similarly, the this call-backs in a template method really define such a reusability contract and should be specified in terms of protected methods.
> 
> We are on a well trod path here. protected is an important paving stone.
> 
> Allen
> 
> 
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110608/09c1ce45/attachment-0001.html>


More information about the es-discuss mailing list