| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On Aug 25, 2006, at 8:25 AM, Wagner Truppel wrote:
I actually like the idea of common operations on strings being able to be added to a string class. There are many times in any language that a string is used to build another object. In that sense the design pattern is that a String creates the other object, much like a Factory method. Consider in Java, the URL class. It has a constructor URL(String spec). In fact all the constructors require either a String or another URL object, so the String is the basis for building the URL. With categories, we could enhance the basic String class such that we could add the method public URL toURL() to the String class. What's cool with categories is that you don't actually bloat the base class, but can use the category just within your application. Thus if your app uses lots of URLs or email addresses, the Factory method could be added to the NSString class with a category. In a sense, this is like subclassing, but without the need to change all of your references to your subclass. In fact, since you might be using other frameworks that return the base class, categories allows you to extend the functionality of those frameworks. That's where categories really show their power, since they eliminate the need for glue code utility classes. Since many classes are actually clusters (Factory classes), the real class they return to you isn't always known, which is what can break subclassing & why it is common for Factory classes to be declared final. Categories allows you to add the missing methods without having to rewrite the whole class. Regards, Niels |
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden This email sent to email@hidden
| References: | |
| >Re: Re: Apple should get behind Cocoa Java (From: Wagner Truppel <email@hidden>) | |
| >Re: Apple should get behind Cocoa Java (From: "Jerry W. Walker" <email@hidden>) | |
| >Re: Apple should get behind Cocoa Java (From: Wagner Truppel <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.