Re: Objective-C Question
Re: Objective-C Question
- Subject: Re: Objective-C Question
- From: Steve Ehrenfried <email@hidden>
- Date: Mon, 22 Sep 2003 04:38:48 -0700 (PDT)
--- Marcel Weiher <email@hidden> wrote:
>
Easy: think superclasses. Objective-C is (for most
>
practical
>
purposes) single-rooted.
Do you mean you can subclass a category, or do you
mean that the methods in the category get inherited by
all subclasses of the class that a category was added
to? Sorry, I'm still learning the language, but I do
understand most OOP concepts.
>
>
Well, if that is your attitude towards the use of
>
categories, then
>
you're probably going to miss the more AOP-like
>
capabilities. "If you
>
don't like this sort of thing, then you'll find that
>
this is the sort
>
of thing you don't like" ;-)
I'm not familiar with AOP, so I won't debate it, but I
was merely pointing out what a Cocoa author had
written about it. He cited that there are several
"large teams" that frown on over use of categories.
I'm sure they have their reasons based on experience.
It made sense to me. The author didn't say that
categories should never be used or that they shouldn't
be "liked". He simply cautioned against their
over-use.
>
> 1) Being a able to make a method and/or class
>
"final",
>
> i.e. it can't be overridden or subclassed.
>
>
That is not in any way a "good" feature. In fact,
>
it is downright
>
awful.
I have to strongly disagree here. There are several
valid uses of it.
>
>
> 2) Being to able to have a partial implementation
>
of a
>
> class, i.e. an "abstract class". (Perhaps Obj C
>
> supports this but I just don't know about it. If
>
there
>
> is, how do you specify that instances of a
>
specific
>
> class can't be instantiated?)
>
>
Objective-C "supports" this in as easy a fashion as
>
you could want:
>
just implement the parts that you find necessary.
OK, I'll be more specific in my question. In languages
like Java or C++ you can implement whatever methods
you like, but if a class doesn't have implementations
for all the methods defined in it and its
superclasses, you can't instantiate it. Is this true
in Obj C, or does it allow you to instantiate a class
even though it may have methods defined in the
interface that aren't implemented? Would this generate
a compile or runtime error?
>
> Great implementation in Java, horrendous
>
> implementation in C++ (the function signature
>
doesn't
>
> specify what exceptions are thrown, so how do you
>
know
>
> [unless it's documented, which it probably isn't]
>
what
>
> you need to catch or re-throw? It's real easy for
>
an
>
> uncaught exception to percolate up the stack).
>
>
Declaration and enforced catching of Java exception
>
is yet another
>
horrible mis-feature of that language.
You don't have to catch every exception in Java; it
can be passed on. You don't say why you think it is a
"horrible mis-feature". It's a great feature if used
right; not every function has to throw something. I
like it because it simplifies error handling, and the
exceptions a method can throw are self-documented. I
take it you just don't like Java and therefore
anything that is Java-only is therefore bad.
>
>
> 4) Being able to specify the access control of
>
members
>
> (public, protected, private). Isn't everything
>
public
>
> in Obj C? Sorry, I'm a newbie here, but isn't data
>
> encapsulation part of the object model?
>
>
Language-enforced levels of access control are yet
>
another quite
>
unnecessary "feature" that just complicate the
>
language without
>
actually adding tangible benefits.
In that case Objective C sucks too. I subsequently
found out that Obj C supports access control for
instance variables, just like C++ and Java. Perhaps
not a lot of people use it.
>
>
> 5) No namespaces (C++) or packages (Java). Again,
>
Java
>
> has a much cleaner implementation and is better
>
> thought through, IMHO. Anything like this in Obj
>
C?
>
>
Although I can understand the theoretical attraction
>
of a namespace
>
facility, I must say that I find a prefix (which is
>
functionally
>
identical) to be practically sufficient. No need to
>
add yet another
>
feature.
I was just simply asking if these were supported in
some way. The reason for namespaces/packages is a bit
outside of the scope of this discussion. That said,
packages do more than just prevent a name collision.
Thanks,
Steve
>
>
Marcel
>
>
>
--
>
Marcel Weiher Metaobject Software Technologies
>
email@hidden www.metaobject.com
>
Metaprogramming for the Graphic Arts. HOM, IDEAs,
>
MetaAd etc.
>
1d480c25f397c4786386135f8e8938e4
>
_______________________________________________
>
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.
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
_______________________________________________
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.