Re: XML as "passive data" (Re: The Browser Wars are
On Wednesday 23 October 2002 08:32, tblanchard@m... wrote: > You know, I'd really like it if people would stop referring to those > two evil twins as "Object Oriented" because, while they manage to fake > a few features of OO, they aren't. > > Based on a couple of other comments like objects "hiding away data" I > can see the reaction against compiler enforced encapsulation. Its bad. > Pure and simple. Public Protected Private is a menace to modern > software development because [snip] Another related issue is the way you can't add methods to existing classes. Say you write an algorithm to generate soundexes of strings, and to compare two strings for sounding alike. Since you can't modify java.lang.String, you have to make them, say, static methods in a class of your own. "Ah!", I hear you shout. "I can subclass String to add my methods!" But alas that doesn't help when you call an existing method that returns a String, since it'll return a standard java.lang.String, not your subclass. Even though your new class has no new fields, just a few extra methods, you can't cast from String to it (although Java could be extended to add this funtionality, I imagine). One answer, which introduces some other complications, is something I referred to in another post - generic functions for methods. In that case, methods aren't declared 'in' classes, it's just done with overloading. "object.method (foo,bar)" is just shorthand for "method (object, foo, bar)". If you define "boolean soundsLike (String a, String b)" then you can write "Alaric".soundsLike ("Anorak") to your heart's content. And you could define "boolean soundsLike (String a, javax.sound.sampled.Port b)" to compare a string to some audio, if you like, then trivially define the same function with the arguments swapped (for it is symmetrical) and another that compares two sampled sound sources for sounding similar. This is real handy for implementing mathematical classes. Take the age old example of vectors, matrices, and scalars. Should the operation of multiplying a matrix by an integer go in the matrix class or the integer class, hmm? ABS -- A city is like a large, complex, rabbit - ARP
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format