Re: Class design question
Re: Class design question
- Subject: Re: Class design question
- From: Ken Tozier <email@hidden>
- Date: Sun, 13 Feb 2005 13:04:35 -0500
On Feb 13, 2005, at 12:50 PM, Jason Jobe wrote:
What methods are being overloaded for each class and what is the nature of the functional variance of each one.
Although not dictionaries, I've adopted the NSMutableDictionary syntax for adding and changing values (ie: setObject:ForKey etc...)
The variance is primarily how big a chunk to read from disk into the one changing instance variable. This variable can basically be any size and any type.
For excellent instruction in data and functional abstractions I would refer you to
Thanks, I'll check it out.
Ken
Structure and Interpretation of Computer Programs
<x-tad-bigger>Video Lectures by Hal Abelson and Gerald Jay Sussman</x-tad-bigger>
at http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/
I highly recommend them.
On Feb 13, 2005, at 12:33 PM, Ken Tozier wrote:
Hi all,
I've been working on a class for about two weeks now and have tried out several different ways of approaching the problem but still don't know the "best" way to write it.
In the first pass I created a very generic class with an array of function pointers to handle the many different data types the class was to handle. The code was very compact but was kind of ugly from the OOP standpoint as it required careful synchronization by the programmer between constants and function pointer indexes.
In the second pass I created dedicated classes for each data type which adheres better to the Cocoa way of doing things, but yielded twenty different classes that vary only in the size of a single instance variable (Much like NSNumber) These classes are very nice in the sense that they're easy to use and code but it seems incredibly wasteful to have 20 different fairly large classes to handle a difference of a single variable.
I thought of using unions for the changing variable, but the data sizes can vary hugely (2 bytes up to megabytes) and for that, unions would cause a lot of wasted disk space.
It seems like this problem is tailor made for C++ templates, write one class and template the changing variable but I've always hated the way you have to call C++ template classes. Also my C++ experience is very limited so don't know if it's awkward to mix it with Objective C.
All three have their plusses and minuses
Option 1 is compact and fast but is "ugly" OOP wise
Option 2 is nice OOP wise but is incredibly bloated
Option 3 may be the best choice but I don't know C++ very well
I'd like to hear everyone's arguments pro and con for the different approaches as eventually others will have to be able to work on the source, not just me.
Thanks for any help
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
- jason
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden