[cap-talk] Singletons Considered Harmfuly

David Wagner daw at cs.berkeley.edu
Wed Mar 31 08:52:00 PDT 2010

Rob Meijer wrote:
>Looking at the object granularity, static class member variables are no
>longer private, but instance variables are. Looking at the method
>granularity, instance variables are no longer private, but locally scoped
>variables are. [....]

Later in your email, you suggest the principle:

  Principle: don't use instance variables if locally scoped variables
  can do the job.

I suspect this principle is uncontroversial: it comes naturally,
and I would expect that any decent OO programmer is already following
this principle.  So I don't see any need to call it out specially or
evangelize it.  I can't recall seeing code that uses instance fields
where a local variable would do the job, whereas use of singletons seems
much more prevalent.

More information about the cap-talk mailing list