Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #17335

Re: OOP in Javascript: Class function to define "classes"

Newsgroups comp.lang.javascript
Date 2012-11-22 03:15 -0800
References <f22def49-83aa-442b-ace2-49a972ff4cab@googlegroups.com> <fpITktE8LRqQFwbV@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD> <2fb269af-9e93-4afe-8134-9fb6cadb9c0d@n5g2000yqe.googlegroups.com>
Message-ID <907fcec2-49a7-4e11-b31e-6b2bd995f549@googlegroups.com> (permalink)
Subject Re: OOP in Javascript: Class function to define "classes"
From Luca Lazzarini <lzzluca@gmail.com>

Show all headers | View raw


S

Il giorno martedì 20 novembre 2012 03:14:18 UTC, Scott Sauyet ha scritto:
> John G Harris wrote:
> 
> > Luca Lazzarini  wrote:
> 
> 
> 
> >> I've recently written a tool that provides a “Class” function in
> 
> >> Javascript and i would like to share it: it is intended to be a really
> 
> >> light copy of the MooTools’s Class function with basic features, to add
> 
> >> a little bit of OOP in Javascript and make the inheritance easier.
> 
> >
> 
> >> Here you can find more about it, examples and sources (it is a post on
> 
> >> my blog, i hope it is ok to post it):
> 
> >> http://nerdstuckathome.wordpress.com/2012/11/14/a-class-function-to-
> 
> >> define-classes-in-javascript-with-mootools-like-syntax/
> 
> 
> 
> The usual best practices here are to post some reasonable portion
> 
> here.  A link is fine, but there should also be enough information
> 
> inline to give us a good idea of what's under discussion.
> 
> 
> 
> I agree with all of John's earlier points, but want to stress this
> 
> one:
> 
> 
> 
> > I think it would be better for you to go back to square 0, think
> 
> > carefully about what you really want to achieve, then devise a scheme to
> 
> > do it that is as clear and simple as possible for users. You now have
> 
> > some experience at doing that kind of thing so it might not be so
> 
> > difficult at the next iteration.
> 
> 
> 
> If you treat what you've done so far as an excellent learning
> 
> experience, and then come back at the problem with a fresh set of
> 
> eyes, you might have a very different approach, and most likely a
> 
> significantly better one.
> 
> 
> 
> You do need to consider how much of this is even necessary.  MooTools
> 
> seems to do a great deal to try to make Javascript look more like
> 
> traditional Object-Oriented languages such as Java.  This necessarily
> 
> loses some of the funky flavor that makes Javascript such an
> 
> interesting (set of) language(s).  And it really gains nothing in
> 
> expressive power or overall simplicity.  All this really does it make
> 
> it *look* as though Javascript is more like a statically typed
> 
> language.  Unless and until we have some of the sealing/freezing
> 
> capabilities of ES5 widely available, none of these attempts to
> 
> replicate such type-safe features will actually provide what they
> 
> claim to provide.  And there is nothing you can do about that.  So as
> 
> well as reconsidering your technique, you really should think about
> 
> whether your basic goal is even sensible here.
> 
> 
> 
> It's not that I necessarily think your code is horribly wrong.  In
> 
> fact, I've only glanced at it.  But I'm not sure you are chasing goals
> 
> worth pursuing.
> 
> 
> 
> Cheers,
> 
> 
> 
>   -- Scott

Sorry for my late answer...
I still have some problems with english, so i hope i have got the most from your answer.
I think my last answer to austincheney, on JSMentors group, explains the goals of the function. i am saying that because i see you are there too.
I wrote about what i see as improvements for the syntax provided by the function Class and my point of view about OOP in Js, using constructors; i see my work as an achievement for the target goals.
What i just wrote is for these your lines:

> All this really does it make 
> it *look* as though Javascript is more like a statically typed
> language.  Unless and until we have some of the sealing/freezing
> capabilities of ES5 widely available, none of these attempts to
> replicate such type-safe features will actually provide what they
> claim to provide.

I would like to encourage the OOP in Js, by my function, but using the native way provided by Js...
If you think i should, i can paste here my answer from the JSMentor group to share it with who could be insterested here.

Thank you,
Luca

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

OOP in Javascript: Class function to define "classes" lzzluca@gmail.com - 2012-11-17 06:25 -0800
  Re: OOP in Javascript: Class function to define "classes" John G Harris <john@nospam.demon.co.uk> - 2012-11-18 16:55 +0000
    Re: OOP in Javascript: Class function to define "classes" Luca Lazzarini <lzzluca@gmail.com> - 2012-11-18 12:28 -0800
      Re: OOP in Javascript: Class function to define "classes" John G Harris <john@nospam.demon.co.uk> - 2012-11-19 16:07 +0000
        Re: OOP in Javascript: Class function to define "classes" Luca Lazzarini <lzzluca@gmail.com> - 2012-11-19 09:37 -0800
          Re: OOP in Javascript: Class function to define "classes" John G Harris <john@nospam.demon.co.uk> - 2012-11-20 14:19 +0000
            Re: OOP in Javascript: Class function to define "classes" Luca Lazzarini <lzzluca@gmail.com> - 2012-11-20 08:21 -0800
    Re: OOP in Javascript: Class function to define "classes" Scott Sauyet <scott.sauyet@gmail.com> - 2012-11-19 19:14 -0800
      Re: OOP in Javascript: Class function to define "classes" Luca Lazzarini <lzzluca@gmail.com> - 2012-11-22 03:15 -0800

csiph-web