On May 2, 2008, at 9:32 AM, Western Botanicals wrote:

http://expresslanevideo.com/transfer/code/CacheTesterh.txt
http://expresslanevideo.com/transfer/code/CacheTesterm.txt

You can use Xcode's unit testing functionality -- built atop Sen:te's OCUnit framework -- to write tests in a standard fashion, rather than creating your own custom test code for everything you do.

I wrote a few posts on my weblog about how to use this in a step-by- step fashion <http://chanson.livejournal.com/182472.html>.

Also, you appear to have a very Java/C#-like coding style. It'd be better to make your Objective-C code fit the style of other Objective- C code you're likely to read in code samples, Open Source projects, and so on:

1.  Do not indent everything between @implementation and @end.
2. Instead of +getInstance, the method to return a shared cache object should be +sharedCache. 3. Your -init method should do "self = [super init]" and check for nil return. 4. Your -get:, -put:with: and -removeItem: methods should be more descriptively named. For example, -objectWithID:, - cacheObject:withID:, and -removeObjectWithID:. 5. Your -run: method should be more descriptively named, for example - pruneCache:. 6. You should have a 2-4 character prefix on your class name, since Objective-C doesn't have Java/C#-style namespaces.

Are you really going to be caching arbitrary objects? Or is this for some sort of database front-end application where you have a more specific row-snapshot class that's going to be cached? If so, you could leverage that to actually get an ID of the object to cache and so on, and rename the class to be something like WBRowCache.

Finally, you're going way, way, WAY overboard trying to make this a singleton. Don't bother with all of the extra work you've gone to -- overriding +allocWithZone:, -copyWithZone:, -retain, -release, - autorelease, -dealloc, -retainCount, and so on -- just create it a normal NSObject subclass with normal instance variables that can be instantiated by +alloc/-init. Then, in your application, *just* use +sharedCache to get at the cache. When the time comes that you need separate instances for different purposes, you won't have to rip anything out, and the work to *ensure* singleton-ness tends to be busywork anyway.

  -- Chris

PS - Instead of posting this stuff on your web site as text files, give <http://paste.lisp.org/> a try. It does useful things like syntax coloring. Oh, and use spaces instead of tabs inside your code, at least when posting it to the web; most web browsers and editors will treat a hard tab in a text file as 8 characters.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to