Python Programming, news on the Voidspace Python Projects and all things techie.


Abstract Reasoning

Hans Nowak recently posted a blog entry about how Wax was probably an anti-pattern... which in programming terms is supposed to be a bad thing.

To quote from the wikipedia reference above :

In computer programming, abstraction inversion occurs
when a programmer creates simple constructs on top of
complex constructs.

The correct way is considered to be the other way round
- to create complex constructs on top of more basic

Abstraction inversion is an example of an anti-pattern.

I suppose that this is like the typical OS - that starts with very simple components, like instructions to move the hard drive head, and read or write individual bits. On top of that you build file systems and operating systems.

In terms of programmers libraries it does seem that abstraction inversion is something to be aimed for. Wax is a very good example. It takes the complexities of the wxPython GUI toolkit and wraps it with a much simpler interface. My module logintools is another good example. It provides a user authentication, user account management, and account administration, framework for CGIs. This can actually be used within Python scripts with the addition of as little as two lines of code. It provides a simple interface to a more complex engine.

In a way ConfigObj is becoming like that. It started life as a very simple config file reader and it still maintains extreme simplicity of use. Creating new config files, and reading existing ones, can be done with single line commands. However it is about to receive a major update (up to version 3.3.0) which will add unicode capability and config file validation [1]. The inner workings of ConfigObj can be quite complex..... but the interface it provides is as simple as possible. This seems to be one of the design principles of Python, which is why it appeals to me so much.

Typing this reminds me of how much I need a spell checker ! I have now completed a basic Spell Checker engine - using PyEnchant. I just need to learn enough Wax to plug it into firedrop [2].

[1]An addition built with Mark Andrews from The Validator class we have built has wider application than ConfigObj - which now has an interface built in to use it.
[2]The blog client tool, also by Hans Nowak, that I am typing this into...

Like this post? Digg it or it.

Posted by Fuzzyman on 2005-02-24 10:19:16 | |

Categories: , ,

Hosted by Webfaction