3 ms·
Yes. Composition over inheritance (http://c2.com/cgi/wiki?CompositionInsteadOfInheritance http://c2.com/cgi/wiki?CompositionInsteadOfInheritance). Oftentimes, t
by Someone 14y ago
Yes. Composition over inheritance (http://c2.com/cgi/wiki?CompositionInsteadOfInheritance http://c2.com/cgi/wiki?CompositionInsteadOfInheritance). Oftentimes, these string-like aren't really strings, but have a string representation that dominates their other uses. For example, http headers are, AFAIK, (key,value) pairs that have the string representation "key: value". A good implementation should discriminated between such objects and their implementation.
If your language introduces needless friction when you try to use composition, I would blame the language before I blamed the string class.
[Aside: in Cocoa, NSString is an abstract class, but for a different reason (http://developer.apple.com/library/ios/ipad/#documentation/general/Conceptual/DevPedia-CocoaCore/ClassCluster.html http://developer.apple.com/library/ios/ipad/#documentation/g...).
That approach is only possible in languages that allow abstract classes that are instantiable, such as Objective-C and Dylan (http://opendylan.org/books/dpg/modularity.html#abstract-concrete-and-instantiable-classes) http://opendylan.org/books/dpg/modularity.html#abstract-conc...]