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


Groups > comp.lang.javascript > #34457

Re: Trying to understand OOP, Umpteenth time

Path csiph.com!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From "Christoph M. Becker" <cmbecker69@arcor.de>
Newsgroups comp.lang.javascript
Subject Re: Trying to understand OOP, Umpteenth time
Date Fri, 5 Jan 2018 15:48:18 +0100
Organization solani.org
Lines 15
Message-ID <p2o37h$41l$1@solani.org> (permalink)
References <ff64c61e-75f0-43c3-b003-a6f2ef8ba3fc@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace solani.org 1515163697 4149 eJwNycERACEIA8CWgiE4lKNw9F+Ct98Vw6K2h8I1GsS66rRrQ3S2im6bf3w6LM8DuMRB3l6oBw1gEIg= (5 Jan 2018 14:48:17 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Fri, 5 Jan 2018 14:48:17 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2
X-User-ID eJwFwQERACAIA8BKCmyTOMhh/wj+w7nZCoKBh7fahs3qq9Kljj1t0HOlw0YxrX2iDAvZXh8WdhB3
Cancel-Lock sha1:Dtyra3vk8l5YldCYONDN8naXCwE=
Content-Language de-DE
In-Reply-To <ff64c61e-75f0-43c3-b003-a6f2ef8ba3fc@googlegroups.com>
X-NNTP-Posting-Host eJwFwYEBwCAIA7CXxELVcxiF/09YEqCxjjPoMTHMdzcNs+AFuWTG3F6pvoURTlevK4r43vkBGdARYg==
Xref csiph.com comp.lang.javascript:34457

Show key headers only | 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