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


Programming > Objective-c > Re: Does it lea...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 12 Topic 985 of 1039
Post > Topic >>

Re: Does it leak? Does it vanish? Or does it just blend? :)

by Don Bruder <dakidd@[EMAIL PROTECTED] > May 29, 2008 at 10:45 PM

In article <2008052922290116807-cmh@[EMAIL PROTECTED]
>, Chris Hanson <cmh@[EMAIL PROTECTED]
> 
wrote:

> On 2008-05-28 11:11:30 -0700, Don Bruder <dakidd@[EMAIL PROTECTED]
> said:
> 
> > I'm also worried about the possibility that the "massaged" data could
> > vanish out from under me once this method exits - Or can it, since
it's
> > stuffed into an instance variable?
> 
> Being referenced by an instance variable implies nothing about the 
> memory management state of an object unless you're using Objective-C 
> garbge collection.
> 
> > "Buffer" is an instance variable of the class this is in - declared as
> > "NSMutableData Buffer;" in the .h file, and initialized (in the class'
> > init method) as "Buffer = [NSMutableData dataWithCapacity:1];" (with
> > appropriate error checking) then later stuffed with the data I get
from
> > a URL - That part is working exactly as expected.
> 
> This should be "buffer", not "Buffer".  Instance variables, instance 
> methods, and local variables begin with a lowercase letter in 
> Objective-C (as in Smalltalk) by convention.
> 
> Yes, I know you might be used to something different.  Every language 
> and framework has its own conventions, others experienced with the 
> language and framework will have an easier time reading and 
> understanding your code at a glance if it follows the conventions 
> they're used to, rather than something you made up.
> 
> Also, +[NSMutableData dataWithCapacity:] doesn't make sense to use in 
> an an initializer, unless you retain the result.  This should be clear 
> from the memory management rules.  I suspect you're not adding data 
> you've downloaded to this buffer, but are actually *replacing* the 
> buffer with another data buffer.  It's a common problem I've seen a lot 
> of lately; I'm not sure what leads people to write
> 
>   NSMutableData *data = [NSMutableData dataWithCapacity:1];
>   data = [something somethingThatReturnsData];
> 
> Basically, you just throw away a reference to the object allocated on 
> the first line and replace it with a reference to the one returned on 
> the second line.  People who do this sometimes refer to "allocating a 
> variable" and that's a bit like confusing a mailbox for the letter 
> inside it...
> 
> > findNSString:startingAt:
> > 
> > is my own personal addition (via the "category" mechanism) to the
> > NSMutableData class, which does exactly what the name implies: Search
> > the NSMutableData object for a target string starting at the specified
> > byte, and returning either NSNotFound, or the index of the byte where
> > the target string begins.
> 
> This should probably be named something like
-indexOfString:initialOffset:
> 
> > - (void)StripOutJavascript
> > {
> >    unsigned Start = 0;
> >    unsigned End = 0;
> >    NSMutableData *TempData = nil;
> >    unsigned char Nothing=0;
> 
> Again, follow the standard naming conventions!
> 
> This should be
> 
>  - (void)stripOutJavaScript
>  {
>     unsigned start = 0;
>     unsigned end = 0;
>     NSMutableData *tempData = nil;
>     unsigned char nothing = 0;
>     ...
> 
> Your code will be far easier for others to take in at a glance if you 
> do so.  Adapt to the conventions of the framework and language.
> 
> >       NSString *TargetString1 = [NSString stringWithCString:"<tr><td
> > colspan=\"9\"><script"];
> >    NSString *TargetString2 = [NSString
> > stringWithCString:"</script></td></tr>"];
> >    NSString *TargetString3 = [NSString stringWithCString:"<script"];
> >    NSString *TargetString4 = [NSString stringWithCString:"<script>"];
> 
> Why are you using -[NSString stringWithCString:] instead of constant 
> NSStrings here?

How else, pray tell, does one GET a constant NSString than by creating 
it? 

No, on second thought, never mind. Your commentary, apparently done with 
the intention of being as gratingly obnoxious as possible, leads me to 
think I'm not interested in any further input from you. 

> 
> I haven't read the rest of the code, sorry.  Your coding conventions 
> are a bit too grating.

Pardon the **** outta me for trying to learn the language and not doing 
it exactly to your tastes.

Sheesh, buddy, lighten up already, wouldja? Great - You don't like the 
way I code. I do it in a consistent manner, and I can understand it, as 
can anyone not doing their best to be a jackass. If you're an example of 
the "helpful" world of Objective C folks, it's a wonder that there's 
anybody other than you coding in it. You've sure convinced me it's 
worthwhile asking a question (which, by the way, you didn't bother to 
answer - must have been too busy trying to find ways to be as much of a 
judgmental prick as you possibly could, I guess) as I try to learn the 
language.

-- 
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
 




 12 Posts in Topic:
Does it leak? Does it vanish? Or does it just blend? :)
Don Bruder <dakidd@[EM  2008-05-28 11:11:30 
Re: Does it leak? Does it vanish? Or does it just blend? :)
Tom Harrington <tph@[E  2008-05-28 18:38:09 
Re: Does it leak? Does it vanish? Or does it just blend? :)
Don Bruder <dakidd@[EM  2008-05-28 18:54:15 
Re: Does it leak? Does it vanish? Or does it just blend? :)
Chris Hanson <cmh@[EMA  2008-05-29 22:29:01 
Re: Does it leak? Does it vanish? Or does it just blend? :)
Don Bruder <dakidd@[EM  2008-05-29 22:45:03 
Re: Does it leak? Does it vanish? Or does it just blend? :)
Gregory Weston <uce@[E  2008-05-30 09:05:22 
Re: Does it leak? Does it vanish? Or does it just blend? :)
Don Bruder <dakidd@[EM  2008-05-30 07:40:14 
Re: Does it leak? Does it vanish? Or does it just blend? :)
Reinder Verlinde <rein  2008-05-30 18:51:51 
Re: Does it leak? Does it vanish? Or does it just blend? :)
Don Bruder <dakidd@[EM  2008-05-30 11:19:27 
Re: Does it leak? Does it vanish? Or does it just blend? :)
William Yeo <wcyeo@[EM  2008-05-30 14:10:05 
Re: Does it leak? Does it vanish? Or does it just blend? :)
Gregory Weston <uce@[E  2008-05-30 18:30:14 
Re: Does it leak? Does it vanish? Or does it just blend? :)
Graham J Lee <iamleeg@  2008-06-11 07:41:08 

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 Oct 10 19:55:17 CDT 2008.