[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 s

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

2007-06-25 Thread Tobie Langel
> Is Base an option for the naming of the parent class? Just to clarify, we're looking for how to name the equivalent of the super keyword in Ruby. (i.e. a reference to the method of the same name in the parent class). > "initialize" is reserved, why not "extends" too - allowing the "Class" > >

[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 m

[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: f

[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 i

[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

[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

[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,

[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 call

[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 usuall

[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 const

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

2007-06-25 Thread Tobie Langel
I really dislike the idea of downcasing these methods or prepending an underscore to them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core

[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

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

2007-06-25 Thread Mislav Marohnić
My proposal is very simple: var Animal = Class.create(instanceMethods, classMethods) Both arguments are hashes of methods and the second argument is optional. There are *no* magic properties in them (like include, extends, mixin) - every key-value pair becomes a regular method. The only "magic"

[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 ea

[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 n

[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

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

2007-06-25 Thread Kjell Bublitz
On 6/25/07, Mislav Marohnić <[EMAIL PROTECTED]> wrote: > 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. I also wish to have method name

[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 m

[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 certai

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

2007-06-25 Thread Mislav Marohnić
On 6/25/07, Adam McCrea <[EMAIL PROTECTED]> wrote: > > For superclass and subclasses, what do folks think about prefixing them > with an underscore and making them "private", in the name of keeping the API > as simple as possible. Do you think you'll actually use them if they are > exposed? To b

[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

[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, For

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

2007-06-25 Thread Ken Snyder
Mislav Marohnic' wrote: > 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: > > Tim

[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* c