April 27, 2004
Is it just me, or is the current fashion for sending jobs offshore (Shell being the latest) in any way reminiscent of the great outsourcing boom of the 80's and 90's? I'm talking about when the IT strategy du jour was to hand over great chunks of your company to IBM, EDS, CSC or Cap Gemini in the expectation of saving millions of pounds (shekels, euros, dollars, whatever) in costs a year?
Does everyone remember how successful that was? I've been involved in a few companies where various IT functions have been outsourced and none of them have ever lasted beyond the initial contract. The end of result is usually that IT returns in house and all talk of cost savings is forgotten. If I had to give a reason for this observed behaviour I would say it is because an external supplier is focussed on maximising their profits whilst an internal team should be focussed on maximising yours. The cost savings are always thought to be in reducing the number of people working on providing your IT services because the supplier you choose must be more efficient than your own people, right? Either that or you can share a mainframe with other companies and reduce your expenses. Oh, hang on, even people who run mainframes don't have spare capacity these days so that argument is shot down very quickly.
That's not to say that you can't outsource/offshore specific pieces of work like development projects or specific infrastructure upgrades. These are the real strengths of outside suppliers. But just shifting bodies from one location to another isn't going to save you any money, in fact it will probably end up costing you more.
April 22, 2004
Date Arithmetic in SQL ObjectDate Arithmetic in SQL Object
Often in a database you will record, for instance, a person's date of birth but want to be able to display their age as well. This looks like a perfect place for a Python descriptor, as described in this how-to.
This is all well and good until you consider the actual date arithmetic. The problem being that Python hasn't, until recently, had a standard date datatype so comparing dates is always a little tricky. This is complicated further when you introduce databases into the mix as they all have their own (slightly different naturally) date datatypes. In essence, with two points in time you could be dealing withfour different interpretations (or data types) one each from the database and Python for either of the dates. Like I said, it can get a little complicated.
The Python standard database API can help us a little here. Although the only requirement for compliance is that the module author provides a Date(year, month, day) method to construct an appropriate date object. The way in which dates are stored is up to the module author. Therefore it isn't possible to take a value returned from one database module and compare it with one returned from another. But we at least have a standard interface to them.
To turn a date of birth into an age we count the number of whole years between the supplied value and today. For which you need to know (in the correct data type) what today is. This is probably best illustrated with an example. Given a SQL object class;
from SQLObject import *
We want to add a descriptor method to return an 'age' attribute, something like;
"Return the person's age in years"
But, of course, we need to define a value for today and make sure the arithmetic returns the correct values.
When you are writing your own database code this isn't an issue, simply use the Date method supplied by your friendly database module to define today and then your arithmetic is on like objects. In SQL Object, however, you don't necessarily know which database module you are using so you can't use it's Date constructor. Although it is perfectly possible to do so if you want. In this solution I'm trying to be as generic as possible, just because I can.
Luckily, Python 2.3 introduced a standard date and time module. So, if we can get our two dates into objects that this module understands then life starts to get easier. For today's date it's quite easy;
What will seal the deal is if we can convert dateOfBirth into a datetime object. My solution is;
bDate=datetime.date(dob.year, dob.month, dob.day)
And yes, the first line is just a shortcut to make the second line look better on a web page. Once we've done this the arithmetic is really rather simple;
And voila, when you get an instance of Person and refer to it's age attribute our method is executed. For instance;
<DateTime object for '1968-10-11 00:00:00.00' at 402eb448>
April 20, 2004
Open Source Databases vs Oracle
All interesting stuff and well worth the read. Ken Jacobs quite rightly says that MySQL is missing some features that have been in Oracle (and PostgreSQL) for quite a while (triggers and views in particular). He says that these features are necessary for "enterprise applications" but misses that point that not that many people are building enterprise apps these days. Those that are generally use object oriented programming languages and object relational mapping tools. Which move the focus of your logic from the database to the application layer. Meaning that you can cope without these advanced features in your database and forgo the cost of the Oracle licenses.
I'm not saying that this is always the right approach, but it's certainly cost effective. I'm not a fan of simply using the database as an object store - as mentioned here - but if that's your architecture choice then there it doesn't matter a lot which database you use.
Just steer clear of DB2 UDB ;-)
Invoking HTML Tidy from VIM
Of course there is. Thanks to paragraph 15.5 on this page I found out that it's a two step process. Within VIM type;
To tell the editor that you want tidy as your compiler of choice (I don't know why, I just make it work), then within your HTML page just save and then type;
And Bob is really your Aunty's live in lover. Tidy will tell you what, if anything, you've got wrong. I love this editor.
April 16, 2004
PythonCard is a GUI construction kit for building cross-platform desktop applications on Windows, Mac OS X, and Linux.
Release 0.7.3.1 includes over 40 sample applications and tools to help users build applications in Python, including codeEditor, findfiles, and resourceEditor (layout editor).
This is the last planned "prototype" release of PythonCard. We've started cleaning up the framework code and finalizing the API for a 1.0 release sometime in early summer. There will be at least two more releases before then, so if you would like to get involved in the PythonCard project, now is a great time to join the mailing list.
All the information you need about PythonCard can be found on the project web page at:
The installation instructions and walkthroughs are available on the main documentation page:
You can download the latest release at:
For a list of most of the samples that have been built with PythonCard and screenshots of them in action go to:
The kind people at SourceForge host the project:
If you want to get involved the main contact point is the Mailing list:
PythonCard requires Python 2.2.1 or later and wxPython 220.127.116.11 or later.
April 13, 2004
VIM and SQL Plus
It's fairly introductory but it is quite thorough and covers how to make VIM your editor of choice within and without Oracle. Particularly interesting is the syntax definition for SQL and PL/SQL.
VIM in Mozilla
Fed up of those nasty textareas in web forms? Banish them from your life with mozex, the Mozilla external editor plugin.
I can now write all of my blog posts in VIM. Life is practically complete ;-)
April 08, 2004
Python better than Java?
The Java programmers that I disparaged in my last post have expressed similar misgivings about using this technology and tend to avoid it like the plague.
Whereas in Python you can extend the language in C, invoke operating system commands, interact seamlessly with java, write extension modules in Python but compile them to machine code and even call Berkeley DB using a a standard interface.
I know which programming language I'd choose.
RDBMS in an Agile (OO) Project
Mark Rittman writes a well thought out and interesting piece today on the role of the RDBMS In an Agile Development Project. Definitely worth a read.
As I've touched on before (with a nod to VS Babu) I think the best approach is to use the strengths of your database in combination with the strengths of your programming language. On the continuum between fully object oriented and fully database centric I think that the sweet spot lies somewhere in the middle. If you veer to far to one side or the other then you are doing yourselves (and your customers/users) a disservice.
Of course all of the Java programmers that I used to work with don't agree with me. But then they haven't got me around to make their databases work any more. So I'll just have to keep an eye out and see what they get themselves into.
If you are interested in the meeting of databases and object orientation a good resource is the Agile Data site.
April 06, 2004
Opening Another file in VIM
Every day I learn to love my favourite editor/ide/programmer's swiss army knife just a little bit more.
Today's reason? Courtesy of this tip I discovered the command "gf". It opens the file whose name is currently under your cursor in another buffer ready for editing. It's a godsend when editing, for instance, the HTML for a web page. Wherever there is a link to another page just place your cursor after the HREF and press the magic keys.