Re: Pros and Cons of Static Methods

From: kevinc (kevinc_at_elp.rr.com)
Date: 05/27/04


Date: Thu, 27 May 2004 15:30:27 GMT

Classes were not meant to become repositories for functions.
Using static methods. What you in fact have, is a function.

perry anderson wrote:
> things are done differently in Java than C++, you are in more of truely
> object-oriented world and thats not just a cute term. static methods are
> really class messages, that is, methods that act upon an entire
> classification of objects not just one instance. it is an elegant means
> by which to send messages to all instances or rather the class itself
> and thats how you have to start thinking.
>
> i know your sort of coming at it from an anti-global variable approach
> but static methods are not the same thing. typically they do not create
> the same hang ups as global methods used in non object-oriented languages.
>
> i could say more but first let me hear back if you understand what i am
> saying
>
> thanks
>
> - perry
>
>
> Axehelm wrote:
>
>> Okay, I'm in a debate over whether or not static methods are a good
>> idea in
>> a general domain class.
>>
>> I'm personally not a fan of static methods but we seem to be using
>> them to
>> load an object. For example if you have an Employee class rather then
>> instantiating an instance you call a static method 'GetEmployees' and it
>> returns a List of Employee objects.
>>
>> I'm looking for what other people are doing and if you feel this is a
>> good
>> or bad idea.
>>
>> Thanks
>>
>>
>



Relevant Pages

  • Re: Pros and Cons of Static Methods
    ... Yes I understand what you are saying and yes I'm ant-global... ... Exposing multiple static methods in place of constructors ... > really class messages, that is, methods that act upon an entire ... For example if you have an Employee class rather then ...
    (comp.lang.java)
  • Re: Pros and Cons of Static Methods
    ... object-oriented world and thats not just a cute term. ... really class messages, that is, methods that act upon an entire ... but static methods are not the same thing. ... For example if you have an Employee class rather then ...
    (comp.lang.java)
  • Re: Pros and Cons of Static Methods
    ... weight should be instance vars, but it would make sense for personCount (the ... > I'm personally not a fan of static methods but we seem to be using them to ... For example if you have an Employee class rather then ...
    (comp.lang.java)
  • Pros and Cons of Static Methods
    ... a general domain class. ... I'm personally not a fan of static methods but we seem to be using them to ... For example if you have an Employee class rather then ... instantiating an instance you call a static method 'GetEmployees' and it ...
    (comp.lang.java)