Top 10 things likely to be overheard if you had a Klingon on your software development team has been around for a while, and remains a favourite of mine.
It must have been at the back of my mind today when I IMed a colleague:
Gargh! I will hunt down this developer and challenge them to battle. Perhaps in death they will learn to remove unused parameters from JSP custom tag definitions.
Rant One
Matt Quail, points to Sun’s Bug Parade evaluation of variance, in which a Sun representative states:
Based on feedback within Sun, we are unlikely to do this for Tiger.
What does “Based on feedback within Sun” mean? It could mean any of:
Most likely, it means none of these. The point is that uninformative statements like “based on feedback within Sun” make it very clear that Java is Sun’s game and nobody else’s. Sometimes their decision making process is in the open, sometimes it’s closed, but Sun make the rules and we just have to trust them if we want to be on the Java bandwagon.
Rant Two
Commenting in Matt Quail’s blog, Mats Henricson rightly points out that the type safety argument is a red-herring.1
On the other hand, there are other, real benefits to be had from more being explicit about the type of collection variables:
I’ll be happy to see casting go. It’s always been the ugliest part of day-to-day Java coding2.
PS: Every argument for not explicitly typing all variables in Java is an argument in favour of Python.
1 Me too.
2 Not counting add-ons like JSPs and EJBs.
My wife is planning something for my birthday next month. She is pretty pleased about it. So far, she has told me that:
Despite (or because of) a light-hearted exchange in the comments section of his blog, Charles Miller pointed me to an e-mail message thread algorithm by jwz.
This document goes into some detail about the problem domain, and describes a straight-forward and easy to implement algorithm. From what I remember of Netscape 3.0, it worked just fine too.
Connor, my ambidextrous five year-old, broke his arm last week. He has a plaster cast around the bottom half of his left arm. He’s quite happy with it, and it hasn’t stopped him doing most things, until yesterday.
Yesterday he came crying to Karen.
Karen: What’s wrong, darling?
Connor: I’ve got sore eyes!
Karen: How did that happen?
Connor: My nose was itchy and I went to scratch it with this hand. (Holds up his cast)
He still had red mark between his eyes this morning.
Every discipline has its diagrams: statisticians have their curves, particle physicists have their dots and wavy lines and software architects have boxes and arrows. Software engineers in particular,1 has a few basic drawings that are used over and over again and I’ll be examining these in the coming weeks.
The first of these irregular articles is The Bus.
The Picture
The Bus is used to show complexity being reduced by moving from point-to-point communications to a sharing a common medium for all communication. Typically, The Bus offers some real advantages, but is oversold.
A full Bus consists of before and after diagrams. These are reproduced below in genuine imitation whiteboard style.2
!/pics/blog/003_arch1_before.gif! Figure 1: Before Using The Bus
The purpose of the “Before” diagram is to convince the reader that point-to-point connections between each element in the problem space is too difficult and too complex. The “Before” picture is omitted in situations where The Bus is the assumed solution to the problem.
!/pics/blog/003_arch1_after.gif! Figure 2: After Using The Bus
The “After” diagram shows a dramatic reduction in complexity and clutter. The reduced number of lines implies reduced costs and better manageability.
Applicability
The Bus is applicable whereever two or more communications mechanisms exist in parallel. For instance:
The most recent incarnation of this is the “Enterprise Service Bus” (see section 3 of this pdf document).
The Pitch
There is often a genuine benefit associated with moving to a common communications medium:
The Lie
This diagram promises to remove all communications barriers between disparate technologies, and in doing so, it lies. One layer up from the amalgamated layer is not integrated. One layer up is still as point-to-point as it ever was.
In other words, The Bus doesn’t solve all the communications problems, just those in certain layers:
Conclusion
The Bus is a powerful tool that every architect should keep in their back pocket. However, if you use it, ensure that your audience understands the limits of the solution you are proposing.
Feedback
Where have you seen the The Bus before? Did it lie? Would you use it?
1 Actually, marketing is worse. If you want a good belly-laugh, have a look at the “Marketing Diagrams” templates in Microsoft Visio 2002. It contains enough nicely shaded pyramid diagrams, quadrant analyses and timelines for five white papers.
2 Sorry, only the black pen was working. All the others ran out.
Charles Miller, in his recent post on Penetration Testing, wrote:
A successful penetration indicates something more than a particular security flaw. It indicates some systemic flaw in network security policies or practices.
and:
If the penetration is successful, it is to… practices and procedures that management should return, to examine how they could be better implemented, or more clearly communicated to employees.
Events and Causal Factors Analysis is a technique for analysing and communicating the systemic and indirect causes of incidents. It would be useful for examining faults in practices and procedures after a ‘successful penetration.’
I was working on a Python based prototype recently, and needed to demonstrate the ability to generate and print reports.
Producing printed material is a tedious thing to do in most programming platforms. Java and MSWindows, for instance, both require a programming to render printed output in the same manner as a GUI is rendered, though with kludges for the different resolutions and the requirement for the user to select an output device. From the little I know about it, the situation in *nix is worse.
PDF files are a way to sidestep some of the problems: the application ‘simply’ produces a PDF, fires up Acrobat Reader and lets the user view and print at their leisure. The trick is finding a usable pdf generation library.
ReportLab maintain The ReportLab Toolkit, an open source pdf generation library for Python. I used in the prototype and was impressed. It:
In addition, simple things “Just Work”. I reused some of the sample code, and my prototype had a multi-page report with page headers and footers (including the page number) in about twenty lines of code.
As for the negatives, I haven’t had enough exposure to it to find anything truly frustrating. Here’s one small thing: a few of the shipped classes are usable, but not completely finished. Comments in the code clearly identified these modules.
One of the demos for wxPython—which I also used on this prototype—showed how to embed Acrobat as an ActiveX control in MSWindows. I integrated that demo code with the prototype and the ReportLab generated PDFs popped up beautifully.
Overall, bouquets to The ReportLab Toolkit. My impressions from four or five hours working with it, are that it is comprehensive and flexible, as well as being stable and mature enough to use for my application.
There was once a man who threw himself into a series of large projects. Eventually, he looked up from his work and reflected :
I hated all the things I had toiled for… because I must leave them to the one who comes after me. And who knows whether he will be a wise man or a fool? Yet he will have control over all the work into which I have poured my effort and skill… So my heart began to despair… For a man may do his work with wisdom, knowledge and skill, and then he must leave all he owns to someone who has not worked for it.
Imagine what he would have been like if he’d been an IT grunt, instead of this.
I live in Sydney, Australia, and am posting this from the safety and comfort of my own home on Friday evening. Meanwhile, many European and American readers will be just starting a day of corporate battle. There is no truth to the rumour that I posted this cheerful thought just to annoy you. :)
Somebody at SpiderLogic points to James Gosling’s comment on the portability of SWT over at Computer World. Dr Gosling makes the point that SWT has been getting as big an uptake as it might have expected to get, and he attributes that to its lack of portability.
By “portability”, the good doctor means, “portability to any Java platform”. The SWT folks have their own definition of portability. SWT currently runs on Windows, GTK, Motif or OS/X
For any forseeable need I have, SWT is portable enough. A choice between SWT and Swing would be made on other factors such as:
I was going to blog on my experiences with CherryPy and WebWare, two Python based application servers. Ian Bicking has made that quite unnecessary with this broad survey, The Web Framework Shootout.
After reading Matt Quail’s blog entry on how horribly hard JDK1.5 will be, I downloaded the early access compiler and started hacking on it.
I played around with a few little programs, then got stuck into PragDave’s Kata 6—read a dictionary of words, find all the anagrams, and print them out.
Here is my code. It gives generics and the JSR-201 enhanced for loop a good work out. The other features—enums, autoboxing, meta-data and static imports—aren’t used.
Observations:
Digression on Variance
Java JSR-014 generics suffer from a problem. Joshua Bloch (quoted by Michael Coté) gives a good nutshell explanation:
An
Integeris aNumber, but aListofIntegersis not aListofNumbers.
A solution to this problem is the experimental “variance” extension to generics, which ships with the early access compiler. These look really cool: there is little difference to users of the generic classes (except that more things ‘just work’1), and they aren’t that much harder for writers of generic classes.
Frankly, programmers2 will need to be discouraged from writing generic classes. They can be difficult to implement in a correct and maintainable fashion. The newly genericised java.util collections classes should be all the generics most of us need, most of the time.
Overall, I have to disagree with Matt. JDK 1.5 is a step forward. “The Masses” (as Matt refers to them) will find their day-to-day coding simplified3. “The Smart People” will need to learn a slightly bigger language—hardly a problem for them.
1 Or, to put it another way, fewer things fail mysteriously.
2 Especially the smart ones that assume that everybody else is as smart as them.
3 And day-to-day simplicity is good, especially in the face of things like this, this or this.
Must be winter – my cat insists on sitting in my lap whenever I’m at my computer.
Over the last couple of weeks, I put together a prototype Python application. It was a proof-of-technology prototype, designed to show that all the libraries and products proposed work together.
After a night’s Googling and reading about various windowing libraries for Python, I settled on wxPython. wxPython’s maturity, cross-platform functionality, flexibility and liberal licensing made it the stand-out choice.
wxPython is a thin layer over wxWindows, a cross-platform C++ GUI library which has been around for more than a decade. This mature base gives wxPython several advantages:
In terms of documentation, wxPython ships with a reference manual and comprehensive sample code. There is also wxPyWiki on-line.
Interestingly, the reference manual is the standard wxWindows manual, and because wxPython is such a thin layer over wxWindows, the manual is surprisingly understandable2. It also highlights the efforts that the wxWindows programmers have gone to to make their API simple and usable.
Another thing that attracted me to wxPython is how well it cooperates with other libraries. The sample programs show you how to embed both PyGame and ActiveX controls. ActiveX is done via win32all.
Threre are a few downsides. First up, wxPython does not have a consistent, high-level architecture for interacting with a business model. A Smalltalk or Java style event framework would have been nice.
Second, the GUI callback mechanism is based around assigning integer IDs to controls. Even though wxPython provides some help generating the IDs, it is still a little clunky and I can see that it would become an issue in a really large application.
There are several GUI builders that work with wxPython: BOA Constructor, wxDesigner and wxGlade are the most obvious. Python Card is a GUI library built on top of wxPython.
Overall, wxPython is a pleasure to work with and one of the more complete and mature GUI libraries I’ve used, in any language.
1 wxPython for Mac has just been released too. The download page says, “It’s still a little rough in places, but most things work.”
2 Though if you don’t already know C++, you might find this guide helpful.
There are few immutable laws in the fast moving world of Information Technology. Take for example, The Law of Software Envelopment, as cited by jwz :
“Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.”
After reading Dominic’s latest post, it’s plain that the law has changed to:
“Every program attempts to expand until it can post blogs. Those programs which cannot so expand are replaced by ones which can.”
On the basis of this, I confidently predict that the Windows Longhorn MSN Messenger will be blog-enabled.
PS: Thanks to Charles Miller for pointing me to jwz’s site for the reference.
You know it’s a true cooking disaster when the chemical bond between the base of the saucepan and the hard black bits is stronger than the metal making up the base of the saucepan.
I had a go at PragDave’s Kata 6 in Python. Finding and printing the anagrams took 11 lines, not counting blank lines and comments. (code)
The next two bits of the challenge—finding the longest anagram and the set with the most anagrams in it—added 9 more lines. A comparatively ugly 9 lines they are too. Two more lines were needed to print the total number of anagrams and the total number of sets of anagrams. (code)
It runs pretty quick too. Running over Dave’s 45,000 word dictionary takes less than a second on my Athlon 2000 (1.66GHz), including the Python interpreter startup.
Anybody tried this in another language and want to compare notes?
Since this is the third time in the last year I've had to look this up, I am making a note on my blog, where it should be easy for me to find :)
From this 'notes on Perl' page, how to inplace edit a file with perl:
perl -p -i.bak -e "s#a#b#" filename
| Flag | Meaning | |
|---|---|---|
| -p | Execute the command(s) for every line. | |
| -i.bak | Edit the given file in-place ".bak" is the extension name of the backup file. | |
| -e | Introduces the command to execute. The command in this case is 's' for substitute. |
See also perldoc.com for information on regular expression syntax and such.
As I’ve mentioned before, I spend days working on a fairly large Java system. The odd piece of code has obviously slipped through code review, probably due to being written the day before a deadline or some such. Today I found this variable declaration:
boolean isFound = Boolean.TRUE.booleanValue();
I showed a cow-orker, who quipped, “Tell me it’s not true.”
I’m sorry, but it’s as true as boolean can get.
In the late 90’s, I went to work at the Sydney Sun Java Centre, since renamed Sun ONE. Much to my delight, there were free bottles of soda in the fridge, and the management preferred we helped ourselves to it rather than take off ten minutes walking to the shops. However, I have a fairly well developed caffeine habit and I was a reluctant to drink too much of the free stuff.
I thought my problems were solved when, in a corner of the floor, I found a Coke machine advertising cans for $1.00. (That’s cheap here in Australia). So I put in my dollar, and pressed the button. The machine gave me a can of Coke and eighty cents change. “Excellent,” I thought and took my Coke and four twenty cent pieces back to my desk.
Next day, I rocked up to the Coke machine again, put in just twenty cents, pressed the button and got my can of Coke. Predrag, the chief tester, happened to be walking by.
He challenged me, “You do realise that there’s Coke for free in the kitchen fridge?”
“Oh, yes, but I prefer these cans to the bottles,” I extemporised, not wanting to own up to being embarrassed about freeloading.
He frowned, and explained, “Well, these machines are for testing on the Coca-Cola job. Those cans are months old, and they’re probably stale. You can keep that one, but please drink the Coke in the fridge in future.” I had been messing up his tests with additional vends, extra money and disappearing cans.
I slunk back to my cube to drink a stale can of test data.
O’Reilly have released a Python Success Stories paper by Guido van Rossum and Alex Martelli (pdf, 1.2Mb). It surveys eight applications of Python, and is aimed at technical managers and architects unsure about whether to investigate Python.
Since it is marketing material, you have to read it warily. It tells the facts truthfully, but upsides are emphasised and downsides minimised.
On the other hand, it will get Python on the radar of many influential IT people. Neat.
You can tell that Python isn’t main-stream yet, simply because the paper had to be written. I remember when Java used to have sucess stories. Here’s some from 1996.
Via Matt Quail, via Oliver Burn.
Here is a card (123kb) that I made for a young friend from church. This is her first year away from home, while she boards at university.
The card contains lessons from my adventures at University (looking back, a lot of them seemed to concern stationery), my favourite psalm, pictures of my children, some junk from my top drawer and a scan of my cat.
Bronwyn’s mother is collecting cards from all of Bronwyn’s friends to put in an album and send to her.