On Sun, Oct 30, 2011 at 1:16 PM, Allen Wirfs-Brock <al...@wirfs-brock.com>wrote:
> > On Oct 29, 2011, at 5:01 PM, Axel Rauschmayer wrote: > > Personally I'd ask whether there is a good reason to have "class" > properties on the constructor. > > > I’m not too fond of them, either. Many current use cases go away with > modules. However, sometimes, you want to define class-specific constants > such as Point.ZERO. > > > "class methods" are often used for purposes such as defining secondary > factory methods or performing management functions spanning all instances > of the class. > > It's true that dynamic prototype languages such as self seem to get by > fine with only instance methods but they do this by placing behaviors that > are not specific to single instances (constant access, factories, etc) on > the instances. Class based languages with first-class classes have > somewhere else to place such non-instance specific behavior, as methods of > the class object. In particular, since "first-class" classes means that > classes themselves manifest as objects, they inherently may have methods. > > As a prototype inheritance language JavaScript could have followed > self-style conventions, but it didn't. In trying to be "Java-like" its > core library was organized in a more class like manner including the use of > "class methods". > > In all languages I have observed, the class methods are used sparingly. A > typical class with have one constructor, perhaps several dozen instance > methods, and only one or two class methods (many classes have none). > Since there are so many fewer class methods than instance methods, it seems > acceptable for it to be slightly less convenient to define them then it is > to define instance methods. > This conversation seems to have topically converged with the other class-related discussion. ( https://mail.mozilla.org/pipermail/es-discuss/2011-October/017680.html ) More pointedly, relevant, real-world support for what Allen is describing can be found here: https://mail.mozilla.org/pipermail/es-discuss/2011-October/017727.html /Rick > > Allen > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss