[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread DK
On Jun 25, 7:50 am, Andrew Dupont [EMAIL PROTECTED] wrote: On Jun 24, 7:48 pm, Tobie Langel [EMAIL PROTECTED] wrote: I personally prefer the following syntax: var Animal = new Class({ ... }); var Cat = new Class(Animal, { ... }); I abhor this syntax. I wish I could put

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Kjell Bublitz
On 6/25/07, Tobie Langel [EMAIL PROTECTED] wrote: initialize is reserved, why not extends too - allowing the Class constructor to automatically extend the new class by just looking at the content of extends. That's an interesting idea, Just rewrote below to better match the rest of

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Gareth Evans
Sorry, my OO is a bit slow. I was sorta meaning like this, to take your current example var Animal = new Class ({ initialize: function () { ... }, say: function () { alert('hi'); } }); var Cow = new Class({ Extend: Animal, Include: [Eatable, Breedable], initialize: .. say:

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Gareth Evans
Is Base an option for the naming of the parent class? Gareth On 6/25/07, Kjell Bublitz [EMAIL PROTECTED] wrote: Parent: Please don't overuse the $ sign. It should be used for utilities and nothing else. Don't mix it in other areas, such as classes. Saying that, i still think it is good

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Kjell Bublitz
Parent: Please don't overuse the $ sign. It should be used for utilities and nothing else. Don't mix it in other areas, such as classes. Saying that, i still think it is good to introduce a parent property .. To make it more convenient, name it parentClass. Easy to adopt and no dollar. Style: I

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Tobie Langel
Yes, keep it lower-case and add an s so it reads better :) Cow-Class extends Animal (and) includes Eatable, Breadable ... Remember that the idea is to distinguish them easily from instance methods, hence capitalizing or prepending a $ sign.

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Kjell Bublitz
On 6/25/07, Tobie Langel [EMAIL PROTECTED] wrote: Yes, keep it lower-case and add an s so it reads better :) Cow-Class extends Animal (and) includes Eatable, Breadable ... Remember that the idea is to distinguish them easily from instance methods, hence capitalizing or prepending a $

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Tobie Langel
still a no-go for me. Classnames are capitialized, methods and vars are lowercase. Its always been that way in all the common coding guidlines .. But if you insist, what about an underscore instead? In JS that's usually implies that the property/method should be considered as private, so I

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Andrew Dupont
On Jun 25, 4:41 am, Gareth Evans [EMAIL PROTECTED] wrote: Is Base an option for the naming of the parent class? I'd vote against it assiduously. It was my problem with Dean's original naming as well. In a deep class structure (Organism Animal Cat) it implies that the method being called is

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Kjell Bublitz
On 6/25/07, Tobie Langel [EMAIL PROTECTED] wrote: still a no-go for me. Classnames are capitialized, methods and vars are lowercase. Its always been that way in all the common coding guidlines .. But if you insist, what about an underscore instead? In JS that's usually implies that

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Tobie Langel
I question whether new Class makes sense as an equivalent to Class.create. The new keyword connotes an instance in JavaScript -- with its own scope and method chain. Not all things being *created* are instances. That's a very valid point. It's unfotunately impossible to make a constructor

[Prototype-core] Re: Template Class (documentation related)

2007-06-25 Thread jdalton
Thanks for in-dept blurb on the differences between the JavaScript Object object and Array. I was trying to dumb it down but your explanation is better suited. As for hacky I was merely looking at the source and the variable named object that it expects as the first argument. Seems to me that it

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Tobie Langel
Subclassing: var Cat = Class.extend(Animal, instanceMethods, classMethods) This is much smarter than Animal.extend(...) because you may wish to have a class method named extend on your classes. Agreed. though I think the Class.create({Extend: Animal, ... }) syntax suggested earlier is

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Skip Baney
On 6/25/07, Mislav Marohnić [EMAIL PROTECTED] wrote: You can't achieve this in JavaScript. Simply let it go. Word. I like Mislav's approach to keep all the OOP functionality in Class. Really don't want anything cluttering up the methods or properties of my classes. No real opinion on the name

[Prototype-core] Inheritance: your thoughts?

2007-06-25 Thread Ken Snyder
Mislav Marohnic' wrote: ... In conclusion, my philosophy is: * no magic properties except initialize * keep the inheritance support code simple and short , otherwise it makes no sense in having it * leave room for users to make their own additions to the

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Mislav Marohnić
On 6/25/07, Tobie Langel [EMAIL PROTECTED] wrote: Class.include(Animal, Enumerable) Class.alias(Animal, ...) How do you handle precedende handled between mixin and instance methods ? Can you rephrase the question please? - no dollar-signs and underscores because they indicate

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Andrew Dupont
I agree with everything Mislav said and would adopt that syntax in a heartbeat. My only concern is with the signature of Class.create and Class.extend. I feel like having instance methods and class methods in adjacent arguments can hurt the readability of the code. If you're skimming a file you

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Adam McCrea
I'm getting more and more convinced that extra magic such as classMethods and aliasMethods are unnecessary. You guys are making some great points. Keeping it simple is best. +1 for sup() ... very low risk of naming conflict, and no ugly symbol (I won't go a far as saying bad design, but it

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Andrew Dupont
On Jun 25, 11:29 am, Ken Snyder [EMAIL PROTECTED] wrote: I'd also like to throw in the idea that we need to prove the final OO-design decisions with use cases. We can write animal-sounds code all day long, but JavaScript is such a unique language, I think we ought to prove the design by

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Mislav Marohnić
On 6/25/07, Andrew Dupont [EMAIL PROTECTED] wrote: Perhaps someone could volunteer to convert a piece of Scriptaculous or Rico just for illustration purposes? Stuff in Prototype that benefits from inheritance: TimedObserver, PeriodicalExecuter, Form.Observer, Form.Element.Observer,

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Ken Snyder
Mislav Marohnic' wrote: On 6/25/07, *Andrew Dupont* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Perhaps someone could volunteer to convert a piece of Scriptaculous or Rico just for illustration purposes? Stuff in Prototype that benefits from inheritance: TimedObserver,

[Prototype-core] Re: Inheritance: your thoughts?

2007-06-25 Thread Tobie Langel
How do you handle precedende handledbetween mixin and instance methods ? Can you rephrase the question please? Sure (there was a handled too many in there): do instance method always have precende over mixins ones ? (from the API you suggest, I suppose mixins are included *after* class