Re: Inheritance and Loaded Libraries
Re: Inheritance and Loaded Libraries
- Subject: Re: Inheritance and Loaded Libraries
- From: has <email@hidden>
- Date: Sun, 7 Aug 2005 16:33:01 +0100
One other thought on writing about inheritance, OOP, etc...
The real trick is getting folk to realise why they might want to use it. Most explanations I've seen use rather dry, theoretical examples that explain the mechanics but don't make the reader click as to why it's actually useful. The worked example I used was an associative list object, which was very simple and general-purpose code, with immediate, obvious and valuable applications; plus the code was complete and functional so folk could steal and use it in their own scripts in classic 'poke it with a stick' copycat fashion, even without reading the rest of the text.
In this respect, AppleScript's lack of a native dictionary type was an absolute boon for me: I spent months trying to grok dry OO theory without being able to see any advantage to it over what I already knew (i.e. procedural programming), but in the end what made the point of OOP click for me was the need to scratch my own itch for a real dictionary object. And since AS didn't offer one, I sat down and wrote my own, and suddenly all that theory I'd read started to make sense and have a practical purpose.
It's an ideal example to write about too since it needs little introduction and you can evolve it from what the user already knows. You can start by showing how to do it procedurally, at first using ad-hoc lists of lists, then formalising it (ADTs) with the data structures being treated as 'opaque' and accessed only via functions provided for that purpose. From there, wrap the data structures and functions in an object, allowing users of that object to forget about the data structures completely and just deal with the object and its methods. You can even demonstrate basic inheritance by refactoring it to create case sensitive and insensitive versions (e.g. this is how AppleMods' Types library provides both case sensitive and insensitive versions of its Dictionary object without resorting to such crudeness as cut-n-paste code duplication).
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden