the class as a namespace

From: Date: Thu, 15 May 2008 09:17:22 +0000
Subject: the class as a namespace
Groups: php.general 
Request: Send a blank email to php-general+get-274359@lists.php.net to get a copy of this message
Is there a notion of the class as a namespace? My understanding is that the namespaces are intended to help organize the classes in large projects (and are not perfect). Is it considered good style to use a class simply to box related functions? For instance, a class called "files", contains functions I need for dealing with files - and the instantiated object is _simply_ used to access these functions - the instantiated object is not a file in itself. Thus what I do is not $INSTANTIATED_OBJECT->save(), but $INSTANTIATED_OBJECT->save($file) (though I could do the first if I first, say, do $INSTANTIATED_OBJECT->file = $file. Accessing the functions using the scope resolution operator (::) avoids the need to instantiate an object, but does not allow the use of $this, and $this can be quite practical in order to group common logic into shared methods within the class and thus make the other methods smaller in terms of code (of course, one could use file::save, file::delete instead of $this->save and $this->delete, but it makes renaming objects more difficult). I would be interested to hear opinions. Iv

« previous php.general (#274359) next »