Skip to content

Instantly share code, notes, and snippets.

@pilky
Created November 21, 2011 17:53
Show Gist options
  • Save pilky/1383369 to your computer and use it in GitHub Desktop.
Save pilky/1383369 to your computer and use it in GitHub Desktop.
- (void)method1:(id)somethingElse {
NSString *identifier = [NSString stringWithFormat:@"%@.%@", [SomeClass someMethod], somethingElse];
MyObject *obj = [[MyObject alloc] initWithIdentifier:identifier];
}
- (void)method2:(id)somethingElse {
NSString *identifier = [NSString stringWithFormat:@"%@.%@", [SomeOtherClass someOtherMethod], somethingElse];
MyObject *obj = [[MyObject alloc] initWithIdentifier:identifier];
}
- (void)method3:(id)somethingElse {
NSString *identifier = [NSString stringWithFormat:@"%@.%@", [YetAnotherClass anotherMethodWithSomethingElse:somethingElse], somethingElse];
MyObject *obj = [[MyObject alloc] initWithIdentifier:identifier];
}
@neilgall
Copy link

If you apply DRY to the design decisions rather than the code detail, an answer everyone agrees on may be more forthcoming. If the format of those strings is essential to the correct operation of your code, I'd wrap that up in a utility method with a name documenting that design decision. If it's just an opaque identifier the above is fine.

@pilky
Copy link
Author

pilky commented Nov 22, 2011

That probably makes the most sense. I mean I could see both sides of the argument with it, I just struggled to justify why you'd do either other than "just because".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment