« June 2005 | Main | August 2005 »

July 31, 2005

simplicity hides real size

Roanoke StarHow big is the star?

One of the "trick"s behind a large, successful web site will be that you won't realise just how big it is - it looks simple and elegant and you leave happy, having found the information that you need / having seen enough (there's a difference there between an informational and an entertainment site).

The star is 88.5 feet tall. It overlooks Roanoke, Virginia. Details. Picture by Graham Ellis, 30th July 2005.

More about Roanoke

Posted by gje at 12:12 PM

More about Graham Ellis of Well House Consultants

July 30, 2005

Training course material - why we write our own

If you come on a Well House Consultants Python course, you'll be taught by the guy who actually wrote the course, and who wrote and developed the Python course material. The same comments apply for a Perl or a PHP or a Linux or a MySQL or a Tcl course.

But developing a course and material is an expensive business. It's said to take 10 days to develop material for one day of training. So is our current policy the correct one for us, or should we consider buying in course materials? An email and a telephone call the other day from IT Courseware on one hand showed me some excellent alternative material, but on the other hand lead me to review, and confirm that we can still offer a very much better product using our own materials and knowledge.

What do we gain from writing our own material?

Editorial control.

The ability to cover subjects that our particular customer base wants to be covered in the way that they want it covered.

The ability to use our style on the notes. For example, most training course notes are pages of "bullet" points whereas ours are much more of a "learning to program in Python" manual that will be useful later too.

The ability to "localise" our training - provide a Python course that's exactly what people want in Scotland, Ireland, Wales and England.

The ability to update the notes rapidly (overnight if necessary!) to reflect new sofware releases, new technology uses and security issues amongst other things.

The ability to provide a tailored course to meet an individual clients's needs.

Material Presentation

The look and feel that we choose is consistent throughout all of our courses, and is suitable for Open Source Programming topics.

We can format our material into A4 binders rather than using the nearest American size too ;-)

Staff Skill and development

Our staff know the subjects we teach anyway, but actually writing the material quickly resolves any obscure areas that they're not sure of before they every present a course, and it clarifies in their mind exactly how a subject can be presented to learners. Better to get this worked out before the students arrive rather than in front of them, at their expense.

Last Minute

The ability to accept bookings and tailoring up until the "last minute". It's not common, but we have accepted bookings after normal close of business one day for a course that starts on the next working day.

What would we gain by buying in material?

Cost and easier systems

I'm going to dispute cost! I think that buying in material would only be a cost saving for the first two or three courses given on a subject - the ongoing license fees for notes would then increase our costs. We're a bit of an "oddball" on this - we write efficiently and do so very much in unpaid overtime - as a hobby, you might say - so that the metrics for Well House Consultants are different to the metrics for other training outfits.

It would certainly be easier to order up (say) half a dozen sets of Perl notes a week ahead of a course that to have to print and bind them ourselves ... ensuring paper and toner stocks, backup systems in case of hardware failure, binder, etc ...

Product Range

We could choose to advertise and present a course on a subject that we didn't really know, or on a subject that we couldn't be bothered to write about. We wouldn't do this, though!

So why might others be tempted to buy in material when we don't

Because they don't have skilled technical authors
Because they don't know the subject well enough to actually write the course
Because they don't have graphic artists available to make a good presentation

Because it's much easier (admin wise) to buy in the materials
Because they don't have the printing / binding resources
and the costs would be lower for them if they lacked enthusiastic efficient writers or if they were only going to be using the material once or twice.

Links:
Further information on our courseware
Download centre, including training note samples
Free coursenotes on Java

Posted by gje at 11:03 AM

Where now for dial-up providers?

We're in a fast moving business, and times change; last year's success company may have based its success on a transient market place that's overtaken by events and it'll have to come up with a new niche and adapt and adopt or die. It does have a strong hand in doing this with its existing customer base, retained profits and skilled technical workforce. The alternative is shrinking - perhaps as part of another organisation - or perhaps going out of business as happened last week to Granville Technologies (I hope I have that right), who assembled the Time and Tiny range of computers and sold them from their chain of around 80 UK stores. Victims of a changing market - 80 stores, 1500 employees and a largely national (UK) market simply didn't give them the volume to compete with the Dells of this world.

The dial in ISP is another business that's having to change - be it Wanadoo, AOL, Demon or another, they're hemoraging dial in customers at the moment - loosing many accounts per month as people get Broadband connected. But if they've been providing a good, appreciated, used service with more than just connectivity they have a big advantage over Granville - they can still offer their "more than" services over the broadband connection and they can offer a continuity of access to their services. Whether (if) people are prepared to continue to pay for those extra services when they purchase broadband is not something that I have the marketing information to comment on, but these companies do have the ability to retain users even if those users are not now paying customers.

Why would an ISP want to be giving its services free to a past purchasers of its services? Well - I'm sure it would prefer them still to be paying, but in the new business model there's other ways of generating income. For example, I search using Google's services, but I don't pay Google for searching. Rather, as a business I pay them for click-through ads and I'm happy to do so knowing how wide a range of interested parties they reach. And as a business, Google *may* come up with something new that's so good that I (as a searcher) want to buy from them. And they'll sure as heck appreciate having me there "on their books" when they want to make that offer.

Posted by gje at 01:53 AM

July 29, 2005

The next technologies

What technology is up and coming?

What will people want to learn about next year?

I'm taking a long weekend in Virginia, USA; visiting close family with Lisa. For many people, an 8 hour flight is something that they're thinking about months ahead - planning, writing lists, packing. We got ready early this time - I had my laptop's "mobile office" updated the day before we left, and had checked that our accoms have internet access. But I still - I confess - left throwing in clothes to the morning of departure; frankly, it's a bit routine and we're set up to make it such. Life / office goes on and you'll still find the phones answered and you'll still get email replies within 24 hours (organisation) or 48 hours (awkward technical questions or detailed proposals).

I love my job.

I love telling people about the wonders of Python, Perl and PHP ... of MySQL and Tcl and Linux. And so - even on a trip like this - I take every opportunity to look, to listen, to learn in our techical field. How can that possibly be? Well - I have a sibling-in-law who works for a major Internet service provider and rubbing shoulders there gives me some flavour from a different perspective (the AOL one), and another sibling-in-law who's such an Ebay user and enthusiast that holidays it's something of a side business for him. In the UK, when we're out with people we can turn into techno-bores. With these two though there's an element of give and take. It's also instructive to listen to Phil talking about his experiences / thoughts in the hospitality (hotel) trade; to some extent, we're in the hospitality trade too as we help people plan their visits to Melksham, and open our doors to them.

But there's more than just family. We walk into PC stores, into book stores, and look / see the latest gizmos and publications on their shelves. Frequently in the past, we've found that a USA trend one year is followed by a similar UK trend 6 to 18 months later and we're always anxious to be fore-warned. This isn't an inveterate rule - I would suggest that Ruby, for example has made a small but significant niche for itself in the USA; in the UK, it seems to have been regarded as "just" another scripting language and folks stick with the old favourites of Perl or Tcl, speciliase through to PHP, or move up to Python.

I'm looking forward, then, to hitting the techno-places and I'll be adding a report in here in the next few days.

Posted by gje at 12:46 PM

July 28, 2005

Making Orangutangs

Dateline Thursday, 28th July.
17:30 London time
12:30 Washington DC time.

I'm seated on a transatlantic flight ... and I'm placed up towards the bulkhead seats where the mothers, babies and toddlers are seated; a full flight and a number of very-much-younger people around. Happy gurgling sounds, shrieks and (relief!) very few screams; the gamble of going for this seat in order to avoid lean-backs ahead of me seems to have paid off.

I'm struck by the mothers (and fathers, let's be PC ... no let's be honest and say MOSTLY the mothers) taking their offspring up the aisle to stretch, entertain, relieve, change ... and in every case leading poor junior along by a hand hauled high into the air. Do you, dear reader, walk along the street or around your house with hand held high, would you be comfortable doing so? So why oh why do we do it to our kids? I recall "reins" from many years ago. I also recall myself having kids who really early on could be guided by words and reason rather than by physical controls. Ah - but perhaps those are slightly later memories, fond ones, of taking two kids totalling no more that 10 years between them to far-flung destinations and, yes, as a lone father at times.

Perhaps it's that history that leaves me mellow as I sit and write here today. Perhaps its elements of that history the leave me that very odd combination of scientist and teacher. Perhaps it's some of that history that leaves me somewhat unphased by whatever my working day might bring.

Written in flight, posted later from solid earth

Posted by gje at 10:38 PM

A year on - should we offer certified PHP courses

It's part of my job to keep my eyes and ears open for emerging technologies and market trends; although I've been running PHP courses for the best part of 5 years, I still need to keep on my toes, update my notes, listen to what people are doing / developing / saying / asking. I watch independent forums to get a flavour for what the community is thinking, and the subject of PHP / Zend certification came up. It seems that no-one there has it, and they don't consider it a priority to be going out and getting it either. Here's what I followed up with ...

It seems a long time ago now that we were invited to join Zend's PHP certification scheme - the invitiation came a few months before the scheme was actually announced - and considered carefully, then politely but firmly declined. It's a path that I had been down and see before with Sun Microsystems and Solaris training, Toplog (as was) and FrameMaker training ... and although I'm reluctant to say that I would never sign up to any of these schemes, I think it's highly unlikely

[rant]

Most certification schemes offer the rookie trainee some peace of mind that the course has at least the backing of a company that's part of the establishment and should know what it's doing. They offer the training company the ability to start courses in a new subject that they really don't know very well and haven't got the notes to present ... and if the training company's lucky, they may get passed sales leads too. They offer the certifying organisation a revenue stream (since they charge the training company for each trainee) and a route through which they can get at newcomers to the technology to sell their products / ways to them. Sound like a "win / win"? Not quite ....

Although the trainee should receive a course to a known agenda, that course will potentially have been dumbed down to fit worldwide requirements - it will be consistent to the lowest common denominator. Potentially, the course will be longer than required and will include material that further the certifier's other interests, such as sessions on their purchaseble hardware or software products. The course tutor won't have had any part in writing the notes, and may not even be too familiar with the subject (I've heard some horrendous stories). And the trainee or his employee will pay a higher daily rate than strictly necessary for this as the certifying organisation will want its $50 a day for each student (or whatever the current amount is).

The trainee's employer, who is probably the person paying for the course, will get a trained employee ... who has a piece of paper he can take around to other prospective employees. In other words, he's paying to loosen his hold on his staff. And he's paying for a course that must be presented as the certifying organisation requires, so it can only be tailored to cover the specialist topics that the employer wants on a special authorisation, case by case basis.

If the training company's well established and already able to provide customers with the training they need at a sensible price and to suit local (country) conditions, a certification scheme removes these abilities to meet their clients needs and at an extra cost. It may bring them extra leads so that they can increas there class sizes (not good for the trainee), and it may save them the need to write material and update their notes in the future.

The certification company is laughing all the way to the bank.

[/rant]

OK - I'm not a great fan. Please take the above comments as being general and not necessarily all applying to the PHP scheme. I can assure you that I took a long and hard look at the scheme in the very early days and decided against offering it. And I remain comfortable with my decision.

I'm not Zend certified myself - I put the money I would have invested in getting the qualification towards a Medditeranean cruise ... during which I spent a day and a half listening to Rasmus Lerdorf, author of PHP, talking about it ....

See link for more on Well House Consultant's stand on certification and individual course descriptions for our comments on the schemes for certain technologies. You can also link to our Technology for PHP, PHP Programming and Object Orientation in PHP public, uncertified, course descriptions. On these courses, we take a maximum of 7 trainees. Each course is tailored to the requirements of the UK market and presented appropriately for the particular group of trainees we get each time.

Posted by gje at 04:56 AM


Useful link: PHP training

Trainer answers phone

It's not usually my job to be answering the telephones - I spend most of my working day standing in front of trainees presenting Python, Perl or PHP subjects to them, and much of the rest of my time discussing their particular uses of the technology with them, or advising them on techniques and issues that arrive during practicals.

But it's fabulous, once in a while, to take over "telephone duty" for a day. It helps me to keep in touch with what's happening at the grass roots and sharp end of the admin and booking functions, even if it surprises the occasional prospective customer that we "risk" letting our tutors speak to customers before they book their courses.

I suggest to anyone in a senior role that they should step into the shoes and role of their team and collleagues just once every so often. It can be a real eye opener. And once they get over the shock it can be a real pleasure for the customers too.

Posted by gje at 04:55 AM

July 27, 2005

No Smoking

Sir Richard Doll, the scientist who confirmed the link between smoking and lung cancer, died recently in Oxford at the age of 92. Link - story on BBC website

One in five deaths in the UK are said to be smoking related ...

Aren't statistics like that hard to comprehend? I've been putting a few figures together and I recon that around 7500 people die in Greater London every month. Which works out as 1500 deaths brought on by smoking every month. Compare that to 32 road deaths on an average month in London, or a total (from all accidental causes) or around 120. Compare it too with the 80 or so deaths so far this month caused by the bombings in London ....

I'm not a smoker. Fellow pupils at school encouraged me to try and, sure, I had the odd one but - thank goodness - I knew enough / never got addicted / was more frightened of the reaction I would get at home than the humiliation of not smoking from fellow pupils. I can't claim that - 30 years plus - ago it was any stength in my own character that stopped me, but thank goodness the other influences for good did so.

With my own kids, I've always taught them the dangers of smoking but mid-life and later years seem so far away when you're a teenager, don't they? Chris took up smoking; got addicted and smoked for a few years - teens into early 20s. Of all the lifestyle issues that I went through with him, he would - I hope - tell you that quitting smoking was always my top pressure point on him; almost (but not quite) to the extend of me saying "no matter what else you do ...". Chris hasn't smoked for - what - a year or two now. Still gets the craving occasionally, he says. I can't take any significant credit for turning him around - that goes to himself and Delene (and I cannot tell you in what proportion) but I must record my utter delight.

For a company and personal blog such as this, I have a general rule that people's privacy - family, friends, customers and colleagues should be respected. You'll find that I very rarely write idenifiably or deeply about others. I've made an exception today. I'm willing to put my principles to one side if there's the slightest chance that this tiny droplet may pop up on someone's screen and move them - if just a tiny step - away from committing delayed, painful suicide through smoking.

Posted by gje at 08:03 AM

July 26, 2005

One mans pleasure is another mans poison

Taking a few minutes break between tasks "j" and "k" for today, I visited a web page designed by its author to be the "worst in the world". In my opinion, the author had failed in his attempt; I have seen worse. And I wouldn't agree with some aspects of his reasoning either.

Our website uses a white base. It's there, specified "white" in the style sheets and / or HTML tags. The "worst in the world" page used a white base too. It was stated as being so boring that web authors should always be able to do better ... and we were treated to pages that had a black base and (of all things) a base of AOL logos if we explored his other pages.

Perhaps these patterned bases are good for some pages that they were used on but I do have to say ... I prefer a base to BE a base - not a distracting layer on which I can lay all the exciting things on offer on my site. Perhaps the use of a strong colour or texture indicates that the author feels that his content is shallow?

The "worst in the world" page included a rambling sentence about Mary' dog. And a picture of Mary's dog, who was a sweet looking hound ... the owner of the page commented that this content shouldn't have been there as obviously no-one was interested in the animal. Wrong, dear critic - it's my view that Mary was interested enough in the beast to go to the trouble of publishing a piece about him.

Posted by gje at 05:54 PM

Moderating wiki, blog, and forum contributions

Co-operative content systems such as wikis, blogs and forums provide a fabulous way for the "Joe Public" to express his thoughts, comment back on topics already mentioned, and add new nuggets of useful information to the online base.

Whilst most Joe Public-s make useful contributions, a few of them (or perhaps their less scrupulous friends) can spoil the cabbage patch for the others. Which means that all such systems need to have limits drawn through something like an FAQ (Frequently asked questions) document, or slightly more formally in an AUP (acceptable use policy). Optionally, the site programmer, owner and operator can require various forms of registration, login or approval scanning to give him some feeling of traceback and to make posting more difficult for autometa - but at the cost of making it harder for the casual visitor who was a good nugget to add. An additional option is to make posting off off-topic advertising material less attractive, and yet another is to apply filters to new data in an attempt to trap unwanted material at the point of conception.

I run a specialist forum here - it's reasonably busy for the niche to which it's targetted. I've got a blog running (you're reading it now - or perhaps its archive if you've not got a box to add your comments), and we run a wiki too. There's even a page rank and review system that invites comments thoughout most of the main site. Why do we run all of these?
- Because we value and solicit the views of our clients
- Because we can use them to write answers of general interest and just to it once
- Because it gives wider exposure to our knowledge, products and views
- Because we teach the technologies and need first hand experience
- Because we enjoy doing it.

So - how do we check / control the external contributions without being overrun with material which is so off-topic that it dilutes the purpose of the medium, or is otherwise outside the AUP?

One of the best control tools is the user community itself. If you allow open posting and editing on a wiki, unsuitable messages can be added easily enough, but an enthusiastic community can remove them within quite a short space of time. On a forum, more formerly appointed senior members (moderators) are given similar powers. But in either case, you may want to add in extra tools these days to prevent the level of this extra traffic overloading and depleting through frustration your golden band of helpers. (John, Bruce, I REALLY value your assistance!)

Reviewing material before it's posted works well enough for a system where the contributions are relatively few, and where an adminsitrator is available frequently enough, and where user's aren't going to be put off by the lack of immediacy. As systems grow and people get more "hooked" on them, that often means that an approval-of-each-post system works well at first, but becomes less and less appropriate as a system grow.

Automated systems for reviewing posts (banning certain user names or certain patterns in the content) is another good way of reviewing material before it's posted and it doesn't suffer from the time delay and workload addition of a manual system - but it's also no more that a rough filter refusing a lot of the clearly inappropriate material, and it's bound to leave some "grey" material if you don't draw the bounds so tight that you reject some genuine traffic.

Registering users before they contribute is another way to restrict the flyposting of adverts and trolling posts (posts that deliberatly pick an argument or otherwise irritate). There's come to be something of a formula for registering users - the user enters, at minimum, an email address and an authorisation is sent to that email address giving a unique piece of information through which the user can log in. At least it proves that the person registering has access to the stated email address, though it could well be a temporary address just set up for the purpose. After the initial authorisation, a password system will be used to let the know user re-connect ... and with that comes the need for password management and the need to provide a way of re-issuing a password to an occasional visitor who's forgotten.

You'll find that automated posting software of the type you're trying to supress may be sophisticated enough to get through a simple registration system these days. That's why some of the big boy systems check that you're a real user by sending you down a graphic with some letters in a peculiar font ./ at odd angles and ask you to type them back in!

Making it unattractive or pointless to post off topic material. Ah - the psychology game - why DO people contribute the material that you don't want? Very often, it's to advertise their own products or their own web sites ... even just to provide links to their own websites for the search engines to find. Site ranking depends on many factors, including the number of links IN to your site and the quality of the sites doing the linking, so if you have a respected and wellplaced contribution system people and automata are going to try to hang on to your coattails and benefit from it.

I've seen a couple of bulletin boards and similar systems recently where the site states either "We use a proxy to provide ongoing links, so adding your site here just to enhance your rating is pointless" or something like "Our robots directives tell search engines that they should not follow links from user contributed pages, so you won't gain anything by adding a link here". I wait to be convinced by the effectiveness of such statements; I fear that the human poster will think "what the heck - anyone who reads the page will see my ad anyway and now that I'm here I may as well post", and that the automatic progam isn't going to be bright enough to read and understand the warning from the site owner.

In summary, you'll see I've come up with no absolute answers. I'm a great enthusiast for user contributions on the Well House Consultants web site - and that's because our business philosophy is based much more on helpful networking than agressive competition (hey - it HAS to be for a training company, hasn't it ? ) and because I've got faith in the quality and value of our product. So let the world shout and hear about it.

Posted by gje at 06:39 AM

July 25, 2005

Tough Love

I've just completed a forum and email answer to a chap who's been questioning me / asking me for support on ((exact technical subject doesn't matter)). It seems that this person is really in a very sticky position at work - I could paraphrase his message to read "I've got to get this working or get out" and my natural reaction has been to do what I can to help. But can I truely help?

My correspondent is very unclear about his specification and what he's trying to solve, and has only a very limited knowledge of the underlying programming language that he's using. He's also writing to me in his second (or perhaps third) language as I don't have any knowledge of his native tongue, and it's at best a frustrating and wasteful exercise for both of us. I've had to turn round and say that, much as I would like to be able to help further, he'll move forward far more effectively if he finds a training course or mentor in his locale / language.

Posted by gje at 08:07 AM

July 24, 2005

BBQ Season

Last Thursday evening, we visited Chris and Delene at their new home between Bristol and Bath ... perhaps some of our customers who came on training courses 3 or 4 years ago remember Delene who had a temporary job with us, and saw in our news logs that she married my son Chris. It was a lovely evening and they're thoroughly enjoying the cottage in the country where they're now living ... I couldn't resist sharing these happy, smiling faces with you.

Posted by gje at 11:31 AM

July 23, 2005

Training course plans for 2006

Yes, you did read that right. Even though it's still the middle of the summer, we've already got training courses booked right through to December and we're planning for 2006. There's a listing of courses for the rest of 2005 and January to December 2006 in our course description area, and a calendar showing the dates (and our availability for private courses) for 2006 in our Wiki.

So what has changed in 2005 and what will be new in 2006? I took this picture during last week's private Python course and it struck me that the trainee is reading from notes printed just a couple of days before the course ran, using on of our laptops that's just a couple of months old, and has been supplied with one of our new "goodie bags" (I'm not keen on that name, but customers keep using it!) containing pen, notepad, mousemat (2005 edition) and the current issue of "Of Course". I also note that he has his own laptop with him too; and that's becoming much more common - indeed, on courses at our training centre we always have one training system available per trainee but we're also happy to let trainees use their own laptop and connect it to our network.

Public Courses

Perl Courses for 2006: We'll be running our regular Perl Programming course regularly throughout the year, and we anticipate that the course will start drifting from Perl 5 towards Perl 6 as dictated by the release of Perl 6 and market uptake. Our advanced courses - Perl for Larger Projects and Perl for the Web are currently scheduled only at the start of 2006; with forthcoming plans for Perl 6, it's simply too early to know exactly what our customer will be looking for 12 months from now.

Python training courses have been a big success in 2005, and will be running more frequently in 2006. Our three day Python Programming course will run as a public course every alternate month at our Melksham training centre and we have additional material that we can use as required to cover more specialist Python topics such as the Qt, Tk or wX GUIs, Jython, Python threading, etc.

We anticipate that teaching PHP classes will continue to be a major part of our work in 2006, and we've scheduled a public PHP course every two months. Alternate 4 days courses will be preceeded by an extra day covering the technology background needed by PHP programmers, and alternate courses will be followed by an extra day covering Object Oriented PHP - typically used on larger projects.

The C and C++ courses that we introduced recently are also scheduled throughout 2006 - there's a C introduction course, and two courses that cover C++ - one course on C++ for trainees without prior C experience and the other course of C++ for people who already know C.

The final programming courses we will be offering are on Tcl, Tcl/Tk and Expect. We've seen a significant increase in interest in [incr-Tcl] - the Object Oriented extension to Tcl and our Tcl programming course has recently been updated to increase the coverage of the OO aspects of the language. It's still a three day course that's usually followed by a two day course on the Tk GUI for user who'll be building graphics. Expect continues to be covered on the basic course.

The other area that we're very active is in the Deployment of Open Source Applications and the provision of training on that deployment. Our Deploying Apache/Tomcat course has been full on several occasions already this year, and will run every alternate month throughout 2006. Our Linux introductions - Linux Basics, Linux Administration and Linux Web Server will run every few months (and will preceed the Tomcat course for anyone who needs both courses). And finally (but far from least) our two day MySQL course will continue to introduce newcomers to SQL and MySQL to the principles of the database, installation and maintainance of MySQL, and how to interface programs in a variety of languages such as Perl, PYP, Python, Java and C to MySQL.

Private Courses

The public courses described above will occupy about a half of our resources ... with the rest used to provide tailored private courses. Private courses can be run at our training centre, or at your offices, and remain the best value if you have four or more trainees requiring the same course at the same time. Very easy to book a private course ... and we provide all the notes, equipment needed and the tutor.

For 2006, we've scheduled public courses for the first two weeks of each month and then left the last two weeks of the month for private courses. We're also altering our travel arrangements for such courses. You will find that you're being charged an extra night's hotel expenses next year for many locations - the roads are getting busier, and with current security scares it's getting less easy to arrive reliably and fresh at your office on the first morning of the course. We have always travelled in our own time anyway, so you won't get any extra travel charges and you will get a much fresher tutor.

Private courses are offered in all the subjects listed above under the public course heading, and we may also be able to help with other features of Perl, PHP, Python, Tcl/Tk, Expect and Linux that are not on the public courses, and also with Ruby training. We're no longer offering private programming training in Java - there simply aren't enough hours in the day for us to offer this and keep up to date on the subject.

And Also ...

Within the last year, we've visited Italy, Greece and Turkey to learn more about Linux, Perl, PHP and MySQL from the original authors and the movers and shakers of those technologies. In the previous year, we took in similar coverage of Python. It's to early to be precise, but I'm expecting that 2006 will see us heading off to one or two distant venues - perhaps to get ourselves up to speed on Perl 6, or perhaps for some other new and up coming technolgy. We remain committed to presenting you with excellent, up to date open source courses thoughout 2006, presented from a position of technical strength by members of our team.

Posted by gje at 01:01 PM

July 22, 2005

What is a callback?

When you write a program, you're usually providing the filling for a sandwich.

At the top level, you have the operating system and the compiler or interpreter for the particular language you're using and this provides you with the mechanism to start and end your program, and for it to share the resources of your computer with other processes. At the bottom level, you call libraries (functions, subs, methods, procs ...) that are provided with the language to perform all those common tasks that are required in many programs - ranging from outputting results to a file and converting dates through validating that a user's input matches a particular regular expression to testing if one number is greater than another. It's your job as programmer to provide the bit between.

Regular code

Example (in Python). Here's a piece of code that takes the number of staff at four companies and works out how many cricket teams there are (potentially) in each company.

def teams(wot):
    return wot/11

def mymap(action,source):
retlist = []
for val in source:
retlist.append(action(val))
return retlist

co_sizes = [27,3,46,129]

cricket = mymap(teams,co_sizes)
print "Number of cricket teams ...",cricket

Python functions / methods called at the bottom level include __div__, __str__, append and print and the results of running the program are:

Number of cricket teams ... [2, 0, 4, 11]

Using a callback

A callback is where a bottom level function (i.e. one that's provided with the language) calls code that you as the programmer provided. In the example above, the main program calls the mymap function, which in turn calls the team function, and both the mymap and the team function were part of the user code. But why? Surely, the running of the same (user) function of every member of a list is a common requirement and the programming language itself should provide the capabilty. And, yes, in Python it does - it's the built in map function ...

def teams(wot):
    return wot/11

co_sizes = [27,3,46,129]

soccer = map(teams,co_sizes)

print "Number of soccer teams ...",soccer

Exactly the same calculation as the earlier example but here ...
user code calls the python function map
python function map CALLS BACK to the user code (the function called teams)

Note the code is much shorter and - once you're aware what's going on - much easier.

Common applications of callbacks
1. Mapping functions such as the example above
2. Sort routines, where the langauge provides the sort management and calls back to user provided functions to work out whether one record comes before or after another
3. GUIs (Graphic user interfaces) where actions are defined in functions / procs that the main event handler calls back to.

Posted by gje at 09:29 AM

July 21, 2005

Feast or famine

One of the aspects of running a small business where we take a relatively small number of reasonably large orders is that I'm always getting the feeling of "feast" or "famine". A few weeks ago, I was seeing a slight slowing down of bookings (hey - I'm a worrier) and a lower level of booking ahead than I've seen in a while ... and yet in the last couple of weeks there's been a surge in enquiries and I'm now looking right forward through the Autumn and looking to arrange November so that we can maximise the training time we have. Even having to tell people of limited availabily of course that are months ahead.

I'm often asked about seasonality in our business and, yes, it exists but it's not exactly what you would expect. Our quiet period is the run up to Christmas and early in the new year, rather than the summer holidays; people tend to take advantage of a quieter time at their place of work to fit in the training that they're otherwise too busy to take, and that bolsters our order book even for months such as August.

Posted by gje at 01:04 PM

July 20, 2005

Managing conflict and disappointment

I wondered what to write on "The Horse's Mouth" today ... but then time ran out before I had to rush down for my hotel breakfast and checkout, so I left the posting here until later and now I'm writing the text during a short lecturing break for posting at the end of the day.

I arrived at my training room, on time (i.e. half an hour before the class) and discovered that in this public building the caretaker had - thinking he was being helpful - already unlocked for me, and opened all the doors and windows to help get me off to a cool start. He's got a heart of gold, but I don't think he understands that there's people around who might love to own a laptop and might help themselves to one of ours ... I find it very hard to be rough or harsh with such agent, but clearly the request that I made yesterday - "please do not unlock until I get there" wasn't understood.

And I didn't tell you ... when I got to my training room, I also had a gentleman that I'd never seen before seated there. "Hello - are you from xxx" he asks, naming the company that I'm training. "No - I'm the tutor" I say and he introduces himself. Problem is ... this is the third day of a three day course, I'm not excpecting anyone extra, I don't have spare notes, and it would be highly disruptive. The solutions turns out to be straighforward - there's a one day "Managing Conflicts" course being run for the same company in a room just up the corridor.

It strikes me that there are elements of my job that involve managing conflicts - from ensuring that I'm provided with a minimum of security for my equipment through diverting people helpfully to the right courses. It comes in at other times too; there's a minorty of trainees who find programming very difficult and can occasionally need a little help through their frustration, and there are just a few times where people feel that we've got limitless resources. The story of the guy who came to our office thinking that he didn't need to book - that he could just pay cash on the door - is one for another day. I really doubt that our business will even get so busy that we can take allcomers without booking as you would expect of a bus service!

Posted by gje at 07:55 PM

July 19, 2005

Overloading of operators on standard objects in Python

In python, everything is an object and operations performed by operators such as + and * vary in exactly what they do based on the class (type) or objects on which they're run.

If I use the * operator on a list, it replicates it ... but if I use it on an integer, it multiplies it ...


apple = [17]
orange = 20

firstfruit = apple * 7
secondfruit = orange * 7

print firstfruit
print secondfruit

Results:


[17, 17, 17, 17, 17, 17, 17]
140

Posted by gje at 05:58 PM


Useful link: Python training

July 18, 2005

Central London Courses - Perl, PHP, Python, Tcl, MySQL

We're constantly striving to improve our courses. Already, the majority of our trainees already arrive with us through the recommendation of others, and we're kept plenty busy ... so we must be doing something right. That's not to say that we can't make things even better / have things run even smoother as we fine-tune our product. There's also very much the need to keep up to date with changing languages and logistics.

If you want a Perl course in the City of London, a Python course in the West End, or a PHP course just off Oxford Street, we can help. You provide a room and the students, and we'll do the rest - we provide laptop computers for each trainee to use, tutor (and a knoweledgable one - the guy who actually wrote the course!), notes, servers ... all we ask you to provide is a room and the students. If you've three or more trainees who need the same course at the same time, a private course such as this makes economic sense.

Of the subjects listed above, Python (and to a lesser extent Perl) are often taught to larger groups, but sometimes (usually in the case of PHP!) you won't have enough trainees to justify a private course. We also run regular scheduled public courses on all of our subjects at Melksham in Wiltshire. From London, take the 07:45 from Paddington on the first morning of the course and we'll collect you from Melksham station. At the end of the course, your train is scheduled to be back in Paddington at a quarter to seven.

I started this piece talking about improvements even on a product that's already pretty d**ned good. What have I to report? A new logisitical setup for on site courses in London - we no longer have any issue with parking as we'll now arrive about an hour before the course starts on the first morning, by taxi. Even last week in the immediate aftermath of the bombs of the previous week, the scheme worked well - a "test under fire" you could call it ... and we anticipate that the systems now in place will allow us to continue to present excellent, reliable, fresh courses for you as things get progressively busier and a little more chaotic in town as the Olympics of 2012, with all the infrastucture work that implies, draws closer.

Posted by gje at 05:37 AM


Useful links: Python training, Perl training, PHP training, Tcl training

July 17, 2005

Exceptions in Python

Rather than having to check ahead of time for every possible error, Python provides an exception handling capability too. Simply try to perform you action, and define what's to be done in an except block if the action you want can't be completed.

Here's an example in which we (try to) read an integer value from the user. If our user types a value that's not an integer, the exception is caught and the prompt repeated

def gnum(prompt):
   while 1:
      try:
         rv = int(input(prompt+": "))
         break
      except:
         print "eh?"
   return rv

first = gnum("First number")
second = gnum("Second number")
print "Sum is "+str(first+second)

By the way - note the use of a named block of code (a function) to avoid the need to repeat code. Good programming practise!

Posted by gje at 10:05 AM


Useful link: Python training

July 16, 2005

Bridging to the customer requirement

Programming languages are like bridges - you can use them to get from where you are to where you want to be.


Some languages (such as Python) are very simple and elegant in their design yet take a tremendous amout of traffic ... perhaps there's a pararallel to London Bridge there ...

... but other languages have grown up over time and are a little less elegant, such as the combination of road and rail bridges (two of the three survive) at Blackfriars:

Further languages - PHP is a good example amongst those that we teach - fulfill a specailist need; in the case of PHP, it's for web programming, and in the case of Tower Bridge, it's the need for a low level crossing which tall ships can pass

All pictures taken on my walk to and from a private course I was presenting in London in the past few days.

Posted by gje at 12:15 PM

July 15, 2005

Getting the lighting right

I never cease to be amazed at the number of expensivley-build, lavishly-equipped modern conference and training rooms that have all their lights operated by a single switch. The walls are well lit in these rooms, which means that the lights have to be switched off in order for anything projected onto them to be seen ... leaving traineed fumbling for keys on their laptops, or straining to read notes and add further annotations to them.

In our own training centre, you won't get the impression of a modern room; there's Georgian plasterwork (cornicing) in the room in our nearly-200-year-old listed building, but there's also five discrete controls on the lights allowing us to provide you with good light onto your notes, while leaving our projector screen dark if we so choose.

Posted by gje at 07:57 PM

A word of admiration for the London cabbie

Tower Bridge Road to Soho, Morning rush hour. I could give you *my* route for the journey and it would be efficient enough; non-Londoners riding with me would admire how I found destination "D" from starting point "X" through the maze of streets. But my cabbie was something special; choosing Southwark Bridge was a Masterpiece, and using the backroads around the Royal Opera House rather than the more obvious Trafalgar Square brought me to where I was optimisically hoping to arrive at 08:45 ... fifteen minutes early at 08:30.

We provide equipment for each trainee to use when we're running private courses. "Provide a room and the students and we'll do the rest" is what we say. And it works well. Usually, customers are able to offer me a parking space of there's good parking nearby but in Central London it can be a bit of a nightmare. I can recall courses in the past where I had to unload across the bus stop at Moorgate station, and overlooking Trafalgar Square, and there's then the problem of how I get the equipment inside AND park up the car at the nearest (half a mile away ;-) ) car park. Hence my using the taxi this time - and it works well; hailed the cab at the hotel, quick, easy, and (the icing on the cake) cheaper than simply parking near here. An easy solution for the future. "Bring 'em on". Yes, please do ask me for a Perl course in the City, PHP on the Edgware Road, Python in Kensington on Linux in Soho. "Can do", and do well.

Plenty more pictures from London this week!

Posted by gje at 06:24 AM

July 14, 2005

A Strengthened City

Central London. Soho. I'm running a Python course here in the sweltering heat of summer in a modern office above the streetside shops and businesses of the area - step out of the front door and you're into an area of streetside cafes and shops selling - well - things that you wouldn't expect to find in your local High Street. Londoners and tourists mingling and going about their sightseeing and regular daily lives.

I drove up to town last night, parked up at a hotel on the border of the conjestion zone, and taxi-ed in to here. I'm quite happy with driving right up to the front door, but parking would have been a joke; as it is, it was easy and I arrived fresh. The back streets hereabouts seem to be limited largely to taxis and delivery vans, and the main traffic on the more major roads seems to be buses ... with perhaps a little more presence that I'm used to of police cars. After all, it's less that a week since the four bombs went off, and less that 24 hours since the news broke that it was probably done by four British suicide bombers. London's had its bombs before and life carries on - it feels that people are pulling more together rather than going their own separate ways and you could almost say it's put the heart into the city rather than torn it out.

But there's real people who have had their lives shattered by the bombs. I arrived early and was seated at reception, and a young lady was chatting with the security staff on the desk. I couldn't help overhearing her talking about her close girlfriend, missing on Thursday and confirmed killed by the bomb on Friday. She was saying how her friend's name is in the papers now, and how seeing the other names listed around she realises that this particular family / group is one of a whole number around London who are going around in a haze - a state of shock. I rode up in the lift with her and it turns out she works where I'm training. Doesn't know how long she'll last today; her life / her pack of cards has been tossed up in the air. It will land with a hole, but I can also tell that it will land in a stronger configuration.

Posted by gje at 07:06 AM

July 13, 2005

What brings people to my web site?

How busy is your web site? How do people find it? Where do they arrive from? If you have access to your log files and they're using the "combined" format that tells you about the referer, you'll have that information - but hidden deeply in what's likely to be a huge file.

Here's a little bit of PHP code that you could put at the top of a page that you're particularly interested in tracking; it'll let you keep a log of how many visits you get from where, maintaining a very simple data file that you can look at from time to time, and reset when you want to start counting again.


<?php

/* Page to report keep tabs of all the various referers */

/* Find the referer */

$whence = $_SERVER[HTTP_REFERER];
if (! $whence) $whence = "-";

$previous = file("reflist.txt");
$repeat = 0;

// If this is a previously know referer, add 1 to the count

for ($k=0; $k $wl = explode(" ",$previous[$k]);
if ($wl[0] == $whence) {
$ncount = $wl[1] + 1;
$previous[$k] = "$whence $ncount\n";
$repeat = 1;
}
}

// If this is a new referer, add it to the know list

if (! $repeat) {
array_push($previous,"$whence 1\n");
$ncount = 1;
}

// Save the new counts

$fh = fopen("reflist.txt","w");
fputs ($fh,implode("",$previous));
fclose($fh);

// Send out the response page (sample)

?>

<body>
<h1>Headline information
This is visit number <?= $ncount ?> from <?= $whence ?><br>
<a href=/demo/fromwhere.php>Reload linking from here</a><br><br>
<h2>Full information ...</h2>
<?= join("<br>",$previous) ?>
</body>

You may Access the demo from here

Posted by gje at 06:16 AM

July 12, 2005

Oops - I got my initial database design wrong

Just once in a while a question comes up on our Opentalk Forum that's so good and of such general interest that a longer answer is worthwhile. Such a question came up yesterday ... and elegantly asked and worded too, so it was a delight to read and answer.

You want a simple database application? Great - so you write the application using MySQL (or some other database) and you hold your data in a single table. Works well at first but then ... the design starts to creak at the seams. Perhaps you have a number of customers listed, and some of them make multiple purchases ... your database starts to contain a whole lot of repeated information which makes it hard to edit when someone changes their address, for example ...

[b]It's so easy to design a database in this way, but how can it be sorted out later?[/b] It's not going to be easy - but I've set down a scheme, with various options, and a piece of PHP to do the task automatically ... and you can find that in the forum archive

Beware - "normalising" your tables - changing from one table to two of more appropriate design - is likely to take you quite a while as you match up entries that aren't quite identical in their common fields but should be, and you're going to have to modify and add an element of complexity to your applications ... they'll have to update multiple tables rather than just one as data is being entered and changed, and they'll need to use MySQL Joins to connect the tables.

Posted by gje at 01:09 PM

July 11, 2005

Instant availability

Even though we were out of the country last week, we were very much "in touch". News that the Olympics in 2012 will be in London reached us via a footnote in an email; news of the London bombings the following day was breaking on a TV in the hotel lobby as we went out to sightsee. And now, some 9 hours after we landed back in the UK I'm able to have pictures of Iceland online, including some that are less than a day old such as the one above - bathing in the Blue Lagoon just a few miles from Keflavik airport.

Posted by gje at 09:01 AM

July 10, 2005

Vik, Iceland to Melksham, England

A long day ... just arrived home shortly before midnight, Sunday. Around about a thousand pictures - a few of the very best to be posted in case anyone's interested. And a whole host of horses's mouthes waiting up my sleeve (if you'll excuse the mixed metaphor)

Edit ... addition ... Link to pages about Iceland ... with pictures!

Posted by gje at 11:37 PM

July 08, 2005

Time calculation in PHP

Looking to calculate using time in PHP? Been provided with some timestamps such as
[23/Jun/2005:00:06:54 -0700]? (That example is from an Apache Log file).

Method:
- extract the relevant parts of the date from the string
- convert months to a number
- convert the numbers to seconds from Midnight, 1.1.1970
- you can calculate using the resulting figure!


function getwhen($dateinfo) {
$month = array("Jan" => 1,"Feb" => 2,"Mar" => 3, "Apr" => 4,
"May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8,
"Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12);
# Note - hour, minute, second, month, day, year order!
$ts = mktime($dateinfo[4],$dateinfo[5],$dateinfo[6],
$month[$dateinfo[2]],$dateinfo[1],$dateinfo[3]);
# Time zone correction
$ts -= $dateinfo[7] * 3600;
return $ts;
}

ereg('(..)/(...)/(....):(..):(..):(..) (...)',$first,$startdate);
$timingfrom = getwhen ($startdate);

PHP's date function can be used to convert it the opposite direction - from a value in seconds from 1.1.1970 into a string.

Posted by gje at 11:25 AM


Useful link: PHP training

July 07, 2005

The training team that's looking out for you

When you book and attend a training course (one of our Open Source courses of anything else), you're booking a very personal service and you want to know the team that's going to handle your booking and actually do the training. So here they are ...

That's me in the centre; I'm the main tutor. You'll notice that my eyes are closed - that's because I have a vision of your application and I train to meet your needs rather than just to a standard agenda. With a maximum of 7 trainees on each public course, we can and do provide something more than just a standard canned product.

To the left you'll see Leah and to the right is Lisa. They've got their eyes open - very much "on the ball" so that if you call in for a newsletter, or to make a booking, it'll be handled knowledgeably, professionally and quickly. As if by magic (and I know it's NOT magic) the service needed - everything from manuals through lunches, marketing material through invoices, and web site updates through data protection registrations appear just exactly as and when needed.

Posted by gje at 09:54 AM

July 06, 2005

From Iceland

As you may have read over the last few days, I'm away this week ... although we have continuity arrangements (thanks, Leah!) to ensure that there's still a daily tip / message here. But when I spotted an RJ45 connector on the wall in this hotel room, I couldn't resist ... having a great time in Sefloss, Iceland ... and more pictures to follow. Here, to start you off, are some of the photographers in the group.

Posted by gje at 12:42 PM

July 05, 2005

CMS - the minefield of Choices

So you want to have a web site on which your contributors can easily edit their content without the need to become experts in web site work. Where they can take a look and feel across a number of pages and each be responsible for their own content, meaning that updates can easily be applied without complex technical input.

Doesn't that sound an attractive proposition? It is - and it also sound very much like the description of a Content Management System. There are a number of systems out there that started simple, but then the complications started. "Wouldn't it be nice if ...." someone said, the core user team agreed and a facility was added. And another. And another. And before too long, what was a simple system has turned into something that complete books are published on. Don't get me wrong - the facilities added are great, and they're wanted or needed by a large proportion of the user base, but the words WITHOUT COMPLEX TECHNICAL INPUT are gone from my original "desire list" - at least at setup stage; it might (no - it should) still be easy for non-techincal users to work with their data quickly and easily, and without deep training.

Open Source Content Magagement systems that follow this model include MidGard and PostNuke (written in PHP) and Plone (written in Python)... and there's a myriad of commercial products out there too that I won't even begin to list. Choosing the RIGHT CMS has become such a complex arena that companies like CMSWorks, Inc will charge you $895 for their "CMS Report". No - I'm not providing a link - there are more cost effective ways to choose!

So - how to choose?

Firstly, have a think about your content and what you MUST do with it, what you really SHOULD do with it, and what it would be NICE to do with it. Think about what you MIGHT be required to do with it in the future too.

Try to characterise what you're looking for ... do you want ...

* A Blog where you and your content providers can post articles from time to time in the form of an on-line newspaper or magazine, and where readers can comment and discuss, perhaps with some controls

* A Wiki where the pages are open to content providers to edit without a loose web - if they see a page that needs alteration, they simply click on edit. Fresh pages and formatting can be added though a simple formatting tag system.

* A Bulletin Board - also known (perhaps more modernly) as a forum, where an active group of people with an interest of your subject post items, comments, discusssions in a series of threads ... typically displayed with the most recent threads at the top, and with information being archived or discarded after a period.

* A Catalogue shop which is a much more formal product sales site. Products can be re-arranged by the content providers, and prices and descriptions changed with appropriate authority, but the scope for creativity that come with a Blog, Wiki or Forum needs to be absent.

* A Content Managament System or CMS. A system whereby content providers can enter and edit data for your web site and have one of a range of standard profiles applied to each contribution. As a minimum, the contributions will need to be automatically managed - indexed, editable, deletable, and it's probable you'll want some sort of search system too.

Secondly, have a look at some of these systems in use. You'll find sucesssful and busy ones (sometimes you might not even be aware that you're looking at a CMS in particular ;-) ) and systems that have been set up and really haven't taken off. Just to get you started ...

* I run a blog called The Horse's Mouth

* We have a Wiki on our web site known as our share data system

* Our Opentalk help boards run as a forum

* As an example of a catalogue shop, have a look at Express Cleaning Supplies which uses our code.

* For a more general, simple, CMS perhaps you'll want to take a look at Greg Pullen - our local estate agent. A straightforward CMS that manages properties for sale and properties for rent, with automatic sorting and indexing.

Third, try out some of the software for yourself - download a couple of Open Source systems, and try them out. Look and listen to their user communities. There's no "one size fits all" here - indeed, I started writing this article when I was asked for my thoughts on the "Exponent" CMS system ... which is one that I hadn't previously come across. I think that my review should be a separate piece though!

Software "names" that come to mind ...

Blog MoveableType

Forum YaBB - now replaced by Simple Machines (SMF Forum). PHPBB.

Wiki Start at Wikipedia where you'll find a string of possibles

Catalogue Shop OsCommerce

General CMS systems Midgard, PostNuke, Zope and Plone ...

Posted by gje at 01:38 PM

July 04, 2005

Vacation Week

Everyone needs an annual holiday - and it'll be ours for the rest of this week. We'll be recharging our batteries in what is said to be one of the most spectacular countries, and one of the most sparsely populated, in this quadrant of the world. A taster will appear here on our return.

Running a small company such as ours that specialises in providing a personal service, vacation time is one of those times when you worry about who's going to answer the phones and what will happen in the event of any crisis. In past years, we've taken great care to ensure that we stay in touch. This year, though, things are a little different. Leah joined us just over six months ago, and has rapidly learnt about what we do and how we do it on top of her technical (Open Source / Web) skills. We're very happy to leave the day-to-day operation (including posting articles to here from my "pool") in her safe hands. Please keep her busy by booking a PHP course for August, a Perl course for September or a Python course for October.

Posted by gje at 05:43 AM

July 03, 2005

Ajax

We thrive on taking note of upcoming technologies - newly opening niches. Sometimes, as with Perl some 10 years ago and with PHP more recently, it becomes a "no-brainer" that we should be getting more heavily involved and - if we like the technology - offering related services and courses. But for the majority of new developments, the case is less clear cut and often we'll do no more than learn to the "overview" level.

Can I place the first time I heard of Perl or PHP? Not exactly, but I can tell you that it was only after a very few mentions indeed that I looked them up. And so I sit here this morning looking up AJAX.

Ajax - Asyncronous JavaScript and XML. In other words, running a web application as a client side Javascript program which accesses data it needs on a server using XML. So Ajax isn't a language or technology in itself - rather it's a bundle of technologies that come together to provide an approach to web appllications. There's a good paper on it at Adaptive Path that will tell you more if you're interested.

One for us? Not really at the moment. Although I might even concede that client side is the best approach for some applications, for many others (perhaps even for most applications), server side has so much going for it. But you never know - I could foresee some of the more dynamic map navigation work that we've been doing of late benefiting from being more client side, and our framed file selector demo that's pure PHP at present could have a much cleaner user interface at the expense of adding yet more technologies in. Perhaps we'll be seeing bubbles of Ajax cropping up for some of the more interactive selection elements of our LAMP applications in the future.

Posted by gje at 06:33 AM

July 02, 2005

Error handling in Tcl through catch

Tcl is a truely interpretive language - and that means that you can get a syntax error if a user makes an illegal entry ... even in the middle of a program running. For example


puts -nonewline "please enter a number: "
flush stdout
gets stdin value
set doubled [expr $value * 2]
puts "Result is $doubled"
puts "application continues ..."

Will run correctly if you enter a number to the prompt as requested:


earth-wind-and-fire:~/jul05 grahamellis$ wish ifex
please enter a number: 17
Result is 34
application continues ...
earth-wind-and-fire:~/jul05 grahamellis$

but will fail if you enter something that isn't a number:


earth-wind-and-fire:~/jul05 grahamellis$ wish ifex
please enter a number: lots
Error in startup script: syntax error in expression "lots * 2": variable references require preceding $
while executing
"expr $value * 2"
invoked from within
"set doubled [expr $value * 2]"
(file "ifex" line 6)
earth-wind-and-fire:~/jul05 grahamellis$

If you want to make your Tcl code rugged against such errors, embed commands that may cause a problem within catch commands. Tcl's catch command returns a true of false result depending on whether or not the embedded command succeeds, and if it fails it also returns the error message decribing the problem in a variable of your choice. Here's the program above, enhanced to catch any errors:


puts -nonewline "please enter a number: "
flush stdout
gets stdin value
if {[catch {set doubled [expr $value * 2]} errmsg]} {
puts "Failed - $errmsg"
} else {
puts "Succeeded and result is $doubled"
}
puts "application continues ..."

And let's try running that. Firstly, with correct data:


earth-wind-and-fire:~/jul05 grahamellis$ wish ifcat
please enter a number: 17
Succeeded and result is 34
application continues ...
earth-wind-and-fire:~/jul05 grahamellis$

And now with data that would previously have caused a crash:


earth-wind-and-fire:~/jul05 grahamellis$ wish ifcat
please enter a number: many
Failed - syntax error in expression "many * 2": variable references require preceding $
application continues ...
earth-wind-and-fire:~/jul05 grahamellis$

This approach described here could be described as an expection handling system as it tries to perform an operation and traps if a failure occurs, rather than trying to predict the error ahead of time. An alternative (error handling) system could have been used, in which the code check the input text string to make sure that it's numeric before the expr command is run. We have a comparison of exceptions v errors in our solution centre.

Posted by gje at 09:23 AM


Useful link: Tcl training

July 01, 2005

Letterbox Pictures

There's a convention that pictures are pushed using a 4:3 or 3:4 aspect ratio and those are known as landscape and portrait formats ... but I've taken a few pictures over the last few days that seem to lend themselves naturally to the 2:1 ratio

You might almost call this a "superlandscape" view of the two Forth Bridges - and there's more Forth Bridge Pictures of a more conventional look on our site too.

Signage is another area where "letterbox" format can be appropriate ...

This is a sign in the centre of Carlisle, taken last weekend ...

Posted by gje at 09:09 AM