Re: Unification of Methods and Functions

From: Neil Benn (benn_at_cenix-bioscience.com)
Date: 05/25/04


Date: Tue, 25 May 2004 13:21:05 +0200
To: python-list@python.org


David MacQuigg wrote:

>On Tue, 25 May 2004 15:31:49 +1200, Greg Ewing
><greg@cosc.canterbury.ac.nz> wrote:
>
>
>
>>David MacQuigg wrote:
>>
>>
>>>My perspective may be different, because I have not yet absorbed the
>>>Python traditions, and I don't have any instictive avoidance of static
>>>methods.
>>>
>>><snip>
>>>
>>>
>>But Python has modules for use as general-purpose
>>namespaces. Classes are thus relieved of the burden
>>of performing this double duty, leaving them free to
>>concentrate on what they do best, which is defining
>>the behaviour of a collection of objects.
>>
>>
<snip>

The point is that a static method defined in a class _is_ a part of the
object model. There are many, many object models where you would have a
static method that _belongs_ to the class.

    For a dummy example :

--
A dodo class which has a method to return a new dodo when it is born.
A dodo class with a static method to return the first ever dodo (the 
uber-dodo!), this is a static method - making the constructor return the 
same dodo each time is counter intuitive.
ALSO
A dodo class static method of Dodo.makeExtinct(), this applies to the 
Dodo class (species) and not to the individual dodo (animal).
--
    In addition, when returning a singleton, that should live in with 
the class as the fact that a class in only available as a singleton is a 
factor of the design of the class and should not be linked to another 
namespace.
    I am a ex-Java/.NET programmer so I admit I'm biased but the problem 
is not language specific, it's design specific.  I do understand that in 
Python this is only syntatic sugar but using a module namespace to 
acheive these needs removes what is a link in the design.
Cheers,
Neil
-- 
Neil Benn
Senior Automation Engineer
Cenix BioScience
BioInnovations Zentrum
Tatzberg 46
D-01307
Dresden
Germany
Tel : +49 (0)351 4173 154
e-mail : benn@cenix-bioscience.com
Cenix Website : http://www.cenix-bioscience.com


Relevant Pages

  • Re: Resolving current namespace
    ... > Is there a way to resolve the current namespace in a static method, ... > Mainfrom within a console app? ... public class MyClass ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Resolving current namespace
    ... >> Is there a way to resolve the current namespace in a static method, ... > public class MyClass ...
    (microsoft.public.dotnet.languages.csharp)
  • Root node in a webservice in a different namespace than the webservice. Is this possible?
    ... XmlSchemaProviderAttribute pointing a static method that adds the XSD ... I have a web service with one method defined in it. ... namespace that is application specific. ... The root element MUST be the Dublin Core element. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Resolving current namespace
    ... Is there a way to resolve the current namespace in a static method, ... In a public method from a class instance, you can use the "this" keyword in ...
    (microsoft.public.dotnet.languages.csharp)