My goal is to be able to create a unique string based on a timestamp and some other information. I will be doing this many times through-out the code base, so code reuse and maintainability implies that I should make one spot to do this.
Since this unique ID will always be stored into an NSString, I could make a category on NSString that will create this unique id...
NSString *uniqueString = [NSString stringWithTimestamp:timestamp andName:name];
Or I could create a custom helper class with a class method to return a unique string string...
NSString *uniqueString = [HelperClass stringWithTimestamp:timestamp andName:name];
Wouldn't creating the helper class typically be better because I can import it into other projects and use that method, as well as other unrelated methods I may have created (easily contained all in one file)? If I used categories, they'd be spread out in a bunch of different files.
But this can't be right, because with this logic there would rarely be a need for categories, and just always create a helper class for a project with these helper methods in it...I must be missing something!
I will suggest the helper class approach since the unique id method has no relation to NSString class other than the return type. Just imagine, in future if you plan to create an NSInteger as unique id then this method wont have any relation to NSString class. So a helper class is the right approach here.