I have a simple method that returns bool, but it internally loads various objects.
I check for null for each, but it becomes very ugly.
Is there a better way?
public bool SomeTest(int id1)
{
bool result = false;
User user = userDao.GetById(id1);
if(user != null)
{
Blah blah = blahDao.GetById(user.BlahId);
if(blah != null)
{
FooBar fb = fbDao.GetById(blah.FooBarId);
if(fb != null)
{
// you_get_the_idea!
}
}
}
return result;
}
Is there a pattern that could make this a more inline instead of nested if's?