Skip to content

Instantly share code, notes, and snippets.

@arialdomartini
Created May 23, 2013 10:20
Show Gist options
  • Save arialdomartini/5635127 to your computer and use it in GitHub Desktop.
Save arialdomartini/5635127 to your computer and use it in GitHub Desktop.
Ti insospettisce questo refactoring?
// Before
public JavaAdvertSchedule GetByWebSite(String website, String checkableFromDay) {
ObjectIterator<JavaAdvertSchedule> result = null;
try {
result = new ObjectIterator<JavaAdvertSchedule>("JE.AdvertLifecycle.Scheduling.Data.JavaAdvertSchedule", "JavaAdvertSchedule_GetByWebsite", website, checkableFromDay);
if (As.Boolean(result.HasNext())) {
return result.GetNext();
}
return null;
} finally {
if (result != null) result.close();
}
}
// After
public JavaAdvertSchedule GetByWebSite(String website, String checkableFromDay) {
ObjectIterator<JavaAdvertSchedule> result = new ObjectIterator<JavaAdvertSchedule>("JE.AdvertLifecycle.Scheduling.Data.JavaAdvertSchedule", "JavaAdvertSchedule_GetByWebsite", website, checkableFromDay);
if (!As.Boolean(result.HasNext())) {
return null;
}
JavaAdvertSchedule record = result.GetNext();
result.close();
return record;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment