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


Groups > comp.lang.javascript > #34457

Re: Trying to understand OOP, Umpteenth time

From "Christoph M. Becker" <cmbecker69@arcor.de>
Newsgroups comp.lang.javascript
Subject Re: Trying to understand OOP, Umpteenth time
Date 2018-01-05 15:48 +0100
Organization solani.org
Message-ID <p2o37h$41l$1@solani.org> (permalink)
References <ff64c61e-75f0-43c3-b003-a6f2ef8ba3fc@googlegroups.com>

Show all headers | View raw


On 05.01.2018 at 15:10, bit-naughty@hotmail.com wrote:

> OK, so I think I get it. If you have a class X (OK, you can't, but maybe by now you can...ugh! I donno, you get my point?), you can say var foo = new X() ; ,and then you can execute stuff *inside* X like this: foo.m() ;.
> 
> But then you can also do var bar = new X();, and then you'd have a second instance of X, right? My question is WHY? Why would you need the same thing twice?? ie. in short, what is the whole POINT of doing OOP? Where would you NEED to do the var bar stuff, after you'd already done the var foo?

new classname() creates a new object instance, what is quite comparable
to a baking machine producing a bread.  If there should be more than one
bread, you have to press the button again.  This again is quite similar
to a car factory, which will produce many cars (not only a single one).
If you want to shiftGear(), accelerate() or brake() a certain car, the
others should not be affected, of course.

-- 
Christoph M. Becker

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


Thread

Trying to understand OOP, Umpteenth time bit-naughty@hotmail.com - 2018-01-05 06:10 -0800
  Re: Trying to understand OOP, Umpteenth time "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-01-05 15:48 +0100
  Re: Trying to understand OOP, Umpteenth time John G Harris <niam@jghnorth.org.uk.invalid> - 2018-01-05 15:14 +0000

csiph-web