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


Groups > de.comp.lang.php > #3592

Re: private property

From Arno Welzel <usenet@arnowelzel.de>
Newsgroups de.comp.lang.php
Subject Re: private property
Date 2015-12-10 16:31 +0100
Message-ID <56699AEC.6010200@arnowelzel.de> (permalink)
References <n4bpsd$ous$1@news.albasani.net> <n4bvin$3e0$1@news.albasani.net> <n4c4ak$cd5$1@news.albasani.net>

Show all headers | View raw


Am 2015-12-10 um 16:04 schrieb Jan Novak:

> Am 10.12.2015 um 14:43 schrieb Niels Braczek:
> 
>> Bis hierher soweit ok.
>>
>>> ...
>>> class generalClassFunctions{
>>> 	public function show($htmlfile){
>>> 		global $_lang;
>>> 		global $_rootdir;
>>
>> *Never* use global!
>> Übergebe diese Daten explizit, entweder der Methode show() oder dem
>> Konstruktor.
> 
> Ist das nicht ein wenig aufwendig, das jeder Klasse jedesmal 
> mitzuteilen? Es handelt sich um die Sprachdatei, ist überall gleich und 
> unverändert (aber das nur am Rande).

Ob aufwendig oder nicht: Eine Klasse sollte nicht voraussetzen, dass es
bestimmte globale Variablen gibt - denn dann kann man auch gleich auf
Klassen verzichten.

Wenn es Dir zu umständlich ist, dass bei show() jedesmal zu übergeben,
dann baue halt eine Methode, mit der man $_lang und $_rootdir einmalig
setzen kann und speichere das dann lokal in der Klasse.

Die Klasse selbst sollte aber niemals irgendwelche externen
Abhängigkeiten in Form globaler Variablen haben.


-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de

Back to de.comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

private property Jan Novak <repcom@gmail.com> - 2015-12-10 13:06 +0100
  Re: private property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-10 14:09 +0100
  Re: private property Niels Braczek <nbraczek@freenet.de> - 2015-12-10 14:43 +0100
    Re: private property Jan Novak <repcom@gmail.com> - 2015-12-10 16:04 +0100
      Re: private property Niels Braczek <nbraczek@freenet.de> - 2015-12-10 16:25 +0100
        Re: private property Jan Novak <repcom@gmail.com> - 2015-12-11 08:06 +0100
      Re: private property Arno Welzel <usenet@arnowelzel.de> - 2015-12-10 16:31 +0100
        Re: private property Jan Novak <repcom@gmail.com> - 2015-12-11 08:04 +0100
          Re: private property Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2015-12-11 07:37 +0000
            Re: private property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-11 16:23 +0100
              Re: private property Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2015-12-12 13:06 +0000
                Re: private property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-12 16:32 +0100
                Re: private property Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2015-12-17 17:40 +0000
                Re: private property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-17 20:02 +0100
                Re: private property Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2015-12-17 19:03 +0000
                Re: private property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-17 20:52 +0100
      Re: private property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-10 19:31 +0100
        Re: private property Jan Novak <repcom@gmail.com> - 2015-12-11 08:03 +0100
          Re: private property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-11 13:17 +0100
            Re: private property Jan Novak <repcom@gmail.com> - 2015-12-14 08:06 +0100
    Re: private property Jan Novak <repcom@gmail.com> - 2015-12-11 11:29 +0100
      Re: private property Jan Novak <repcom@gmail.com> - 2015-12-11 11:39 +0100
        Re: private property Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-11 14:56 +0100
          Re: private property Jan Novak <repcom@gmail.com> - 2015-12-14 08:15 +0100

csiph-web