Какова наилучшая практика при вложении вызовов методов или использовании одноразовых переменных?
Если вы никогда не используете одноразовые переменные?
пример:
[persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType
configuration:nil
URL:[NSURL fileURLWithPath: [applicationSupportDirectory stringByAppendingPathComponent: @"storedata"]]
options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption]
error:&error];
Стоит ли всегда разбивать вложенный метод на одноразовые переменные?
пример:
NSNumber *yesNumber = [NSNumber numberWithBool:YES];
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:yesNumber
forKey:NSMigratePersistentStoresAutomaticallyOption];
NSString *urlPath = [applicationSupportDirectory stringByAppendingPathComponent:@"storedata"];
NSURL *url = [NSURL fileURLWithPath: urlPath];
[persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType
configuration:nil
URL:url
options:optionsDict
error:&error];
Или вы должны использовать какую-то комбинацию из двух?
пример:
NSDictionary *optionsDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
forKey:NSMigratePersistentStoresAutomaticallyOption];
NSURL *url = [NSURL fileURLWithPath: [applicationSupportDirectory stringByAppendingPathComponent:@"storedata"]];
[persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType
configuration:nil
URL:url
options:optionsDict
error:&error];
Я склоняюсь к комбинации двух, но мне хотелось бы услышать, что все остальные скажут по этому поводу. В случае, если выше не ясно, эти «одноразовые переменные» создаются с единственной целью разбить вложенный метод и не будут использоваться нигде.