Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!novia!news-out.readnews.com!transit3.readnews.com!postnews.google.com!u12g2000prc.googlegroups.com!not-for-mail From: lewbloch Newsgroups: comp.lang.java.programmer Subject: Re: A question about some long java code that has getters/setters Date: Mon, 25 Jul 2011 15:56:59 -0700 (PDT) Organization: http://groups.google.com Lines: 21 Message-ID: <7241d106-caca-4137-a060-ecd2d5fa2eb8@u12g2000prc.googlegroups.com> References: <1672e2f1-a963-4fcf-b651-41b69432c9d7@p29g2000pre.googlegroups.com> NNTP-Posting-Host: 172.19.62.109 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1311634982 16222 127.0.0.1 (25 Jul 2011 23:03:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 25 Jul 2011 23:03:02 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u12g2000prc.googlegroups.com; posting-host=172.19.62.109; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ASELCHRU X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1,gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6555 On Jul 25, 1:27=A0pm, Patrick May wrote: > lewbloch writes: > > It is standard practice to create accessors and mutators for class > > attributes. =A0There's nothing wrong with that. > > =A0 =A0 =A0Actually, there is. =A0It encourages a style of programming wh= ere > objects have too much knowledge about each other. =A0Encapsulation is > important; objects should ask each other for services, not manipulate > each others internals. =A0With the exception of cases like DAOs, getters > should be very rare and setters non-existent. You don't create them for hidden members! Yeesh. By definition the attributes are those that you want to make public. What you choose to make public should be a matter of design, not dogma. I do not endorse making attributes public that shouldn't be. -- Lew