Created
November 21, 2011 17:53
-
-
Save pilky/1383369 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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]; | |
… | |
} |
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
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.