Re: static vs non-static. Recommendation needed.
Re: static vs non-static. Recommendation needed.
- Subject: Re: static vs non-static. Recommendation needed.
- From: Gregory Weston <email@hidden>
- Date: Mon, 13 Apr 2009 07:59:12 -0400
ok5.admin wrote:
Hello.
A foreword:
In my application I need to allow the user to create a database. So i
display a dialogue panel, collect all the necessary information about
the db to be created and create a "DatabaseInfo" object. Then i pass
that DatabaseInfo object to the DatabaseCreator to actually create the
needed database. I want the DatabaseCreator to "return" an sqlite3
pointer.
...
Is it all right to init an object just to dealloc it in the next line
(or create an autorelease object using a convenience method for that
matter)? I mean, if i made it non-static, i would have something like
this in the class that uses it:
DatabaseCreator *dbc = [DatabaseCreator creatorWithDBInfo: dbInfo];
sqlite3* database = [dbc database]; // and dbc would no longer be
used.
Or is it better to put up with the inconveniences of having that thing
static?
It's better to follow the practice that you'll find most maintainable.
But I might suggest you've omitted a couple of options. Would it be,
for example, particularly evil if your DatabaseInfo object include a
createDatabase method?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden