× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Yes. Accessors are Evil.

The author (this was written in 2003) points out correctly that
accessors are PROCEDURAL artifacts. If you design your classes and
methods well, there's no need to access the instance values of an object
other than through the methods of the class (class methods and instance
methods). The author also points out that database interface IS
PROCEDURAL; that database access requires procedural code. Still, I try
to design my database interface such that it implements object
persistence. The class can instantiate from a database and serialize an
instance to the database but it doesn't have to. The object could stand
alone without the database if I could keep memory refreshed infinitely.
Methods on the object (eg, Employee.increasePay(int bumpUp)) update the
database and maintain values in the object. I might have a class method
such as Employee.instantiateFromDatabase(String empno) that will do all
the fetch necessary.

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of James Perkins
Sent: Tuesday, February 03, 2009 3:06 PM
To: Java Programming on and around the iSeries / AS400
Subject: Java Accessors Are They Evil?

Hello All,
I realize this article is kind of old, but I found it interesting none
the less.
http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html

I just can't figure out how you can get around getters and setters. I
understand it makes more sense to build a method to calculate a discount
or something like that, but what I don't understand is how you create an
object based on data from a database?

Maybe I'm over thinking this or taking what the author is writing too
literally, but I'm curious to see what some of you more experienced Java
developers think.

James R. Perkins
--
This is the Java Programming on and around the iSeries / AS400
(JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/java400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.