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


Groups > comp.lang.java.help > #2465

Re: When to use static methods?

Newsgroups comp.lang.java.help
Date 2013-01-17 15:13 -0800
References <kd9pmg$dt4$1@dont-email.me> <kd9sdk$vf2$1@dont-email.me> <1db42ef8-752e-4ef6-ae60-b818820f5da7@googlegroups.com>
Message-ID <ac730659-b391-4ba1-8089-29456703157a@googlegroups.com> (permalink)
Subject Re: When to use static methods?
From Lew <lewbloch@gmail.com>

Show all headers | View raw


Lew wrote:
> ... Or in short form: Favor instance methods over static, unless compelled otherwise.

Addendum: The "depends on instance state" criterion is circular reasoning, if you have 
mis-architected your type to have mutable static member variables on which the method 
depends. Then a judgment of "depends only on global state" is a consequence of the 
design error that there is global mutable state.

So that rule is more safely expressed as "depends on mutable state". This helps you 
realize that mutable state should be instance state.

-- 
Lew
All rules have zero exceptions, ever.

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

When to use static methods? Steve <tinker123@gmail.com> - 2013-01-17 16:15 -0500
  Re: When to use static methods? markspace <markspace@nospam.nospam> - 2013-01-17 14:02 -0800
    Re: When to use static methods? Lew <lewbloch@gmail.com> - 2013-01-17 15:04 -0800
      Re: When to use static methods? Lew <lewbloch@gmail.com> - 2013-01-17 15:13 -0800
  Re: When to use static methods? Roedy Green <see_website@mindprod.com.invalid> - 2013-01-17 15:01 -0800

csiph-web