Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #29574
| From | Tim Streater <timstreater@greenbee.net> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Newbie trying to understand object oriented programming |
| Date | 2016-02-07 13:16 +0000 |
| Message-ID | <070220161316290875%timstreater@greenbee.net> (permalink) |
| References | <664696a0-3ce3-484c-aeaf-2fdf45781bb4@googlegroups.com> <9cydnYY0F6n_AyjLnZ2dnUU7-fOdnZ2d@westnet.com.au> <9ffad5b6-4de6-463c-b919-bd139402c94e@googlegroups.com> |
In article <9ffad5b6-4de6-463c-b919-bd139402c94e@googlegroups.com>,
<bit-naughty@hotmail.com> wrote:
>On Saturday, February 6, 2016 at 12:49:07 PM UTC+5:30, RobG wrote:
>
>> So *this* references an
>> object that is a new instance of *vegetables*.
>>
>
>
>Ahh - THIS was the sentence that taught me the most out of everything you guys
>said.
>OK, well, this is going to take some time to sink into my brain, I'm just
>going to have to sleep on it till I get it.
>
>WHY have they done all this? Like, why have things been laid out this way? The
>idea behind OOP is that - MANY programmers will be collaborating on ONE piece
>of software, right? Like "Vegetables" will be written by somebody else, and
>I'll just be instantiating it, and using its insides in my code, without
>caring about what it's inside it, right? First of all, how do I know that
>it'll be called "Vegetables" - do I have to chat with the guy who wrote it and
>ask him/her what he/she called it inside his/her code???!!!
>Is an easy way to learn this stuff to use *libraries*, where I will, have to
>call, code that someone else wrote, I mean, that's the whole point of a
>library, of course.....
>
>I find the statement "this.colour=colour" inside the function that someone
>said very confusing, can we just name the variables separately, like
>"this.hue=colour", it's still the same thing, "potatoes.hue" will then be
>"brown",right? How do I then get "tomatoes.hue" to be "red"?
It will be brown only because you insisted on putting:
this.colour = "brown"
inside your object constructor. You should have put:
spuddy = new vegetable ("brown")
and for the constructor you have:
function vegetable (colour)
this.hue = colour
then you'll be doing:
tomahto = new vegetable ("red")
I though this had already been pointed out?
--
"Please stop telling us what you feel. Please stop telling us what your
intuition is. Your intuitive feelings are of no interest whatsoever,
and nor are mine. I don't give a bugger what you feel, or what I feel.
I want to know what the evidence shows." -- Richard Dawkins
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Newbie trying to understand object oriented programming bit-naughty@hotmail.com - 2016-02-05 06:55 -0800
Re: Newbie trying to understand object oriented programming 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-05 18:56 +0000
Re: Newbie trying to understand object oriented programming Tim Slattery <tim@risingdove.com> - 2016-02-05 14:07 -0500
Re: Newbie trying to understand object oriented programming Aleksandro <aleksandro@gmx.com> - 2016-02-05 17:34 -0300
Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-05 19:10 -0800
Re: Newbie trying to understand object oriented programming 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-06 08:33 +0000
Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-06 08:24 -0800
Re: Newbie trying to understand object oriented programming 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-06 18:48 +0000
Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-06 12:28 -0800
Re: Newbie trying to understand object oriented programming 4ndre4 <4ndre4@4ndre4.com.invalid> - 2016-02-06 21:01 +0000
Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-07 15:23 -0800
Re: Newbie trying to understand object oriented programming Aleksandro <aleksandro@gmx.com> - 2016-02-08 11:45 -0300
Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-02-08 13:39 -0800
Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-11 08:09 -0800
Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-02-11 12:22 -0800
Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-12 11:09 +0000
Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-02-12 13:34 -0800
Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-13 14:40 +0000
Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-02-14 10:18 -0800
Re: Newbie trying to understand object oriented programming Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-02-14 21:27 +0100
Re: Newbie trying to understand object oriented programming "J. Clarke" <j.clarke.873638@gmail.com> - 2016-05-14 10:13 -0400
Re: Newbie trying to understand object oriented programming Tim Streater <timstreater@greenbee.net> - 2016-05-14 16:47 +0100
Re: Newbie trying to understand object oriented programming "J. Clarke" <j.clarke.873638@gmail.com> - 2016-05-15 07:05 -0400
Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-14 10:08 -0700
Re: Newbie trying to understand object oriented programming "J. Clarke" <j.clarke.873638@gmail.com> - 2016-05-15 07:02 -0400
Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-15 13:11 -0700
Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-05-15 17:03 +0100
Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-15 13:20 -0700
Re: Newbie trying to understand object oriented programming Gene Wirchenko <genew@telus.net> - 2016-05-16 11:55 -0700
Re: Newbie trying to understand object oriented programming Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-16 21:39 +0200
Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-17 07:30 -0700
Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-05-17 15:34 +0100
Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-13 17:50 -0800
Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-14 11:15 +0000
Re: Newbie trying to understand object oriented programming "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-02-14 11:03 -0800
Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-15 20:18 +0000
Re: Newbie trying to understand object oriented programming Scott Sauyet <scott.sauyet@gmail.com> - 2016-02-13 16:54 -0800
Re: Newbie trying to understand object oriented programming Danny <dann90038@gmail.com> - 2016-02-05 15:00 -0800
Re: Newbie trying to understand object oriented programming RobG <rgqld@iinet.net.au> - 2016-02-06 17:18 +1000
Re: Newbie trying to understand object oriented programming Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-02-06 16:01 +0100
Re: Newbie trying to understand object oriented programming bit-naughty@hotmail.com - 2016-02-07 04:47 -0800
Re: Newbie trying to understand object oriented programming Tim Streater <timstreater@greenbee.net> - 2016-02-07 13:16 +0000
Re: Newbie trying to understand object oriented programming John Harris <niam@jghnorth.org.uk.invalid> - 2016-02-07 17:29 +0000
Re: Newbie trying to understand object oriented programming bit-naughty@hotmail.com - 2016-02-08 08:53 -0800
Re: Newbie trying to understand object oriented programming Tim Streater <timstreater@greenbee.net> - 2016-02-08 17:33 +0000
Re: Newbie trying to understand object oriented programming Joao Rodrigues <jr@none.com> - 2016-02-06 11:56 -0200
csiph-web