<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-6098392112071095875.post7226251200934459312..comments</id><updated>2012-02-04T21:36:06.292-05:00</updated><category term='Hibernate'/><category term='Code'/><category term='Productivity'/><category term='Opinion'/><category term='Spring'/><category term='Performance'/><category term='Agile'/><category term='Java'/><category term='Scrum'/><title type='text'>Comments on Code Instructions: Getters and setters are Evil</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.codeinstructions.com/feeds/7226251200934459312/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/7226251200934459312/comments/default'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/08/getters-and-setters-are-evil.html'/><author><name>Domingos Neto</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_HHFrwTieqY8/STh7yQ1m0bI/AAAAAAAAABs/8BJWpydZgZ4/S220/cruzes.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-3356809253480727799</id><published>2009-12-26T18:49:54.318-05:00</published><updated>2009-12-26T18:49:54.318-05:00</updated><title type='text'>I want to quote your post in my blog. It can?
And ...</title><content type='html'>I want to quote your post in my blog. It can?&lt;br /&gt;And you et an account on Twitter?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/7226251200934459312/comments/default/3356809253480727799'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/7226251200934459312/comments/default/3356809253480727799'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/08/getters-and-setters-are-evil.html?showComment=1261871394318#c3356809253480727799' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/08/getters-and-setters-are-evil.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-7226251200934459312' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/7226251200934459312' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1698902322'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-3539479653342189049</id><published>2008-10-04T22:24:00.000-04:00</published><updated>2008-10-04T22:24:00.000-04:00</updated><title type='text'>Well, but how to handle interfaces to the things o...</title><content type='html'>Well, but how to handle interfaces to the things out of the system? For example, how to put/get data into/from databases? Or to/from GUI widgets?&lt;BR/&gt;You can cite Naked Objects, but that assumes OO is "the" way we all should interact with automated information systems, which I strongly disagree.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/7226251200934459312/comments/default/3539479653342189049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/7226251200934459312/comments/default/3539479653342189049'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/08/getters-and-setters-are-evil.html?showComment=1223173440000#c3539479653342189049' title=''/><author><name>M</name><uri>http://www.blogger.com/profile/12041279614721173438</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/08/getters-and-setters-are-evil.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-7226251200934459312' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/7226251200934459312' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1699109530'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-1383499500948743276</id><published>2008-08-03T16:36:00.000-04:00</published><updated>2008-08-03T16:36:00.000-04:00</updated><title type='text'>Hi Tim,&lt;br&gt;&lt;br&gt;If getters and setters are evil, ma...</title><content type='html'>Hi Tim,&lt;BR/&gt;&lt;BR/&gt;If getters and setters are evil, making your attributes public is even worse :)  This is not what I was trying to suggest here.&lt;BR/&gt;&lt;BR/&gt;I understand your point about how to build a DTO and I agree that it should not be the Domain Object's responsibility to do it.&lt;BR/&gt;&lt;BR/&gt;This is the kind of 'real life' problems I was talking about, and this is why I cannot be purist and advocate the end of getter and setter methods.&lt;BR/&gt;&lt;BR/&gt;What is important is to make sure you expose only what is strictly necessary.  If you have to add a setter or a getter fine, just ask yourself if you really need it before doing it.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/7226251200934459312/comments/default/1383499500948743276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/7226251200934459312/comments/default/1383499500948743276'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/08/getters-and-setters-are-evil.html?showComment=1217795760000#c1383499500948743276' title=''/><author><name>Domingos Neto</name><uri>http://www.blogger.com/profile/16748499695622931125</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/08/getters-and-setters-are-evil.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-7226251200934459312' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/7226251200934459312' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1013888231'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-9146127306527328101</id><published>2008-08-03T00:50:00.000-04:00</published><updated>2008-08-03T00:50:00.000-04:00</updated><title type='text'>Hmm... I'm not so sure "evil" is the word I'd use....</title><content type='html'>Hmm... I'm not so sure "evil" is the word I'd use. Inelegant, yes. But rare is the client-server beast that I have seen where your fully OO business classes can be blindly serialized across the ether without concerns for bandwidth and/or memory usage. The solution for this typically is a DTO. But then whose job is it to create the DTO? If your answer is the object itself, then you are digging yourself into the hole of presentation-specific concerns (what happens when the next screen wants to see different data?). Also, how do you create one of these objects from data entered by a user screen? A giant constructor?&lt;BR/&gt;&lt;BR/&gt;I guess the point is that getters/setters provide false encapsulation. Ok, so go ahead and make the attributes public. The problem with that is when you finally decide you want to slip in that "if" statement before the value is gotten (or setten), for example for lazy loading and caching. To do that, you'd have to go back and manually change all direct references to the attribute.&lt;BR/&gt;&lt;BR/&gt;So, if they're evil, I'd say they're a lesser evil, or just plain inelegant. C# got it right, IMHO. ALL references to attributes are implicit calls to getters or setters. You don't have to write the stupid method if all it does is return or set the value. But if the day comes when you DO want to slip in a Mickey, you can explicitly declare the mutator without any change to your class' clients.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/7226251200934459312/comments/default/9146127306527328101'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/7226251200934459312/comments/default/9146127306527328101'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2008/08/getters-and-setters-are-evil.html?showComment=1217739000000#c9146127306527328101' title=''/><author><name>Tim</name><uri>http://www.blogger.com/profile/02875419702912127791</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2008/08/getters-and-setters-are-evil.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-7226251200934459312' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/7226251200934459312' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-269403390'/></entry></feed>
