Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Help > Trivial/stupid ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 3780 of 3882
Post > Topic >>

Trivial/stupid naming convention/cosmetics query - What would YOU do?

by Don Bruder <dakidd@[EMAIL PROTECTED] > Jun 22, 2008 at 02:26 PM

Humor my OCD :) 

I have a method (as part of a category adding on to NSMutableData) I'm 
trying to name in a "by the conventions" fa****on. It works fine - 
nothing wrong there. I just don't like the way the method declaration, 
or calls to it, look - it seems "klunky". So I wonder how other folks 
would name it to make it more "elegant".

As an NSMutableData object loaded with arbitrary data, it needs to hunt 
for two "magic strings" within itself, grab the data between those two 
"magic strings", turn it into an NSString, and hand it back to the 
caller. The "magic strings" might be practically any length, and it's 
typical that they wont have any resemblance to each other - For 
instance, the first one might be "Magic String 1 ", and the second might 
be " Blow It Out Your Ear". Given that, and the (admittedly contrived) 
block of data that follows, I need the NSString that comes back from an 
invocation of the method to be "This Is The Part I Want":

The data block:
This is just some random garbage that I'm typing as an example Magic 
String 1 This Is The Part I Want Blow It Out Your Ear and more data 
follows that may or may not be related

For the moment, I've got the method coded like so:

// MyNSMutableExtensions.h
// elide boilerplate #im****ts and other irrelevancies to save space
@[EMAIL PROTECTED]
 NSMutableData (MyExtensions)
- (NSString *)GetStringDelimitedBy:(NSString *)Delim1 
EndingWith:(NSString *)Delim2;
// elide more irrelevancies
@[EMAIL PROTECTED]
 assuming "TheObject" is an NSMutableData object holding (at least...) 
the data block shown above, the following code hands me back "This Is 
The Part I Want" in Result - exactly as I want it to:

NSString *Result;
NSString *MS1 = @[EMAIL PROTECTED]
"Magic String 1 ";
NSString *MS2 = @[EMAIL PROTECTED]
" Blow It Out Your Ear"

Result = [TheObject getStringDelimitedBy:MS1 endingWith:MS2];

Like I said, it WORKS fine. But my personal sense of style says it 
*LOOKS LIKE* complete crap.

How would *YOU* name such a method?

Special note on my intentions:
I need to use this method many times, with at least a dozen (so far... 
that number is quite likely to increase as the project develops) 
different sets of "Magic Strings", so it's probably best to keep the 
naming as generic as practical, while still retaining as much "self 
do***entation" as possible. As I've got it coded right now, it seems to 
me like it's lacking in the "self do***entation" department, despite 
being absolutely perfect in the "Does one thing and does it well" 
category.

-- 
Don Bruder - dakidd@[EMAIL PROTECTED]
 - If your "From:" address isn't on my
whitelist,
or the subject of the message doesn't contain the exact text
"PopperAndShadow"
somewhere, any message sent to this address will go in the garbage without
my
ever knowing it arrived. Sorry... <http://www.sonic.net/~dakidd>
for more
info
 




 3 Posts in Topic:
Trivial/stupid naming convention/cosmetics query - What would YO
Don Bruder <dakidd@[EM  2008-06-22 14:26:02 
Re: Trivial/stupid naming convention/cosmetics query - What woul
Gregory Weston <uce@[E  2008-06-22 17:40:31 
Re: Trivial/stupid naming convention/cosmetics query - What woul
Don Bruder <dakidd@[EM  2008-06-22 16:11:27 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 10:40:04 CST 2008.