Continuing on with my EO indoctrination, I think I understand the
concepts ok, but when it comes to fleshing the concepts out into
actual code I'm still struggling. I was hoping before I get too along
down a wrong road, one of you experts might take a look at a small
function I've added to one of my EO Objects. This function basically
traverses down several EO Relationships and loops through an array of
EO Objects at the end, looking at the state of an attribute
(selectedItem) in each one in order to determine a result to return.
public class Pool extends _Pool {
private static Logger log = Logger.getLogger(Pool.class);
// Question 1: Does a function like this really belong down in my EO
class.
// There's something about doing the actual Fetches in this class
that rubs
// me the wrong way, however I don't want to put it in my Component
classes
// either since there may be multiple components that would like this
// functionality.
// Question 2: If it does belong down in my EO class, does it belong
in THIS EO class,
// which represents the "top of the chain"
// in a chain of relationships that are traversed to get the actual
data to
// return? Or should I just fetch the entry from here first and move
this function down
// into the Entry EO Class?
// Question 3: Does this need to be static?
public boolean hasResults(EOEditingContext ec, String poolName,
String entryName) {
EOQualifier poolQual = Pool.NAME.eq(poolName);
EOQualifier entryQual = Entry.NAME.eq(entryName);
boolean results = false;
// Question 4: Is exception handling always the best way to handle
the
// no results case? OR should it be saved for cases where
not finding
// what you're looking for indicates there is something
really wrong with
// your app?
try {
Entry entry = Pool.fetchRequiredPool(ec, poolQual).entries(
entryQual).objectAtIndex(0);
// Check first round to see if any actuals have been set.
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 7; j++) {
// This call is to the Mike Schrag approved "game"
function from
// my previous message (see below).
if (entry.game(i, j).selectedItem() != 2) {
// If selectedItem isn't 2 for any game, results have been
posted.
results = true;
//Break out of loops
i = 4;
j = 7;
}
}
}
// Question 5: Do I need any other exception handling?
} catch (NoSuchElementException e) {
results = false;
}
return results;
}
}
On Apr 4, 2008, at 11:50 PM, Jeff Schmitz wrote:
Hello
As I get rolling down the EO highway, I find myself wanting to put
convenience functions in the model classes that are generated by the
EOGenerator (yes, I'm using the generation gap classes for this).
e.g. to more closely mimic indexing a two dimensional array like the
"old" way I used to do things, I create the following to retrieve a
Game object from in from a model class that contains a one to many
relationship to Game objects:
public Game game(int group, int gameIndex) {
EOQualifier gameQual =
Game.GROUP.eq(group).and(Game.GAMEINDEX.eq(gameIndex));
Game game = this.games(gameQual).objectAtIndex(0);
return game;
}
Is this a good thing? Just hoping to get some feedback before I go
too far down this road.
Thanks,
Jeff
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/jeffandmonica%40mac.com
This email sent to [EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]