• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scripting stylistic question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting stylistic question


  • Subject: Re: Scripting stylistic question
  • From: has <email@hidden>
  • Date: Tue, 5 Apr 2005 18:14:33 +0100

Adam Wuellner wrote:

>'Code Complete'

Second that. Basic programming knowledge and techniques I got from reading high school textbooks (always a good place to start), but beyond that much of what I know about good design and programming practice I learned from CC. Also: practise, practise, practise. As you read CC, look at lots and lots of code - both your own and others' - and critique the hell out of it, identifying what's good and what's bad about it and making improvements.

Learning how to program is orthogonal to learning how to read and write code in a particular language, so don't worry that CC doesn't mention AppleScript directly as this is a complete non-issue. Also, don't bother reading CC from cover to cover: chapters are largely self-contained, so you can dive in and just read the bits you're interested in as-and-when you need them and in whatever order best suits you.


In addition to knowing how to write good, clean, well-structured code, the other thing is to know your way around the particular tools you're dealing with: the AppleScript language, Apple Event Object Model, and scriptable applications you're dealing with. That'll help you avoid stuffing up your code with any clumsy, bloated or error-prone cruft, for which future maintainers (including yourself) will be grateful, e.g.:

    repeat with adRef in ads
        set adnumber of adRef to text 2 thru -1 of adnumber of adRef
    end repeat

is both better code and easier to read than your original sample.


Really the only AS-specific tip I'd give is: don't try to be clever. Write your programs to be good code, not "good English". Well designed code that makes good use of functions, constants, comments, etc. is worth its weight in gold, and will definitely make your code more readable and easier to understand. Gratuitous spatterings of 'the's, stupid keyword arguments, inconsistent syntactic forms, etc. won't, and will just twist you, your code and its readers into knots.

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

  • Prev by Date: New to OS X question: scripting desktop picture
  • Next by Date: minimum function?
  • Previous by thread: Re: Scripting stylistic question
  • Next by thread: RE: Scripting stylistic question
  • Index(es):
    • Date
    • Thread