Re: RFC: Allocating via a protocol/interface
Re: RFC: Allocating via a protocol/interface
- Subject: Re: RFC: Allocating via a protocol/interface
- From: Edwin Zacharias <email@hidden>
- Date: Tue, 2 Jul 2002 07:50:43 -0400
On Tuesday, July 2, 2002, at 01:32 AM, Michael Gersten wrote:
Ok, misunderstanding. I don't want to create a new class structure.
I want to create an instance of a class.
But when I'm writing my code, I don't know what class it will be. I
know the API that I want to use. I know the properties that I want to
use.
OK, I see what you want to do now. Since you're not worried about
security you could put all the info about the bundle in its Info.plist,
although you're limited in terms of data structures then.
The idea is to say that all such allocation, instead of using hard
coded class names, goes through some extendable "Here's what I want to
do".
I think I understand this. You want your function to operate like a
class cluster for every class. You want it to pick the best class for
your requirements and return that. Often times this is not about
interface, it's about implementation. For example, all the NSString
subclasses have the same interface. The best one is chosen because of
its implementation. There will have to be some way to define how good
your class is at certain tasks. For example, you could define an array
that's very good at linear searches but bad at random searches. Or good
at appending items, but bad at inserting them in the middle.
The only way I can think to do this is to create a system where classes
can define their abilities using common keywords and then rank them.
For example:
MyNewArray = {
abilities = {
"linear search" = 9;
"random search" = 4;
"append object" = 8;
"insert object" = 1;
"sparse objects" = 9;
"very large" = 6;
"very small" = 1;
};
protocols = (
"NSObject",
"NSArray",
"NSCoding"
);
};
Of course, a valid ranking system would be pretty difficult.
- Edwin
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.