Posts RSS Comments RSSTwitter 18 Posts and 33 Comments till now
This wordpress theme is downloaded from wordpress themes website.

Archive for the 'General' Category

Django JavaScript Integration: AJAX and jQuery

Django JavaScript Integration: AJAX and jQuery is a book about the building of Ajax-enabled web applications using Django and jQuery.  Django has rapidly shot to fame as the most popular web development framework for the Python programming language.  Similarly, jQuery has taken the Javascript world by storm as a client-side Javascript framework making the development of sophisticated browser based clients both easier and even more pleasurable than using Javascript alone.  The strapline to this book is: “Develop AJAX applications using Django and jQuery” and I would suggest that this describes the aim of the book more accurately than its title.

There’s a wealth of both online and dead-tree texts covering Django and jQuery, however by comparison, there’s far less information covering the integration of both technologies so the arrival of this book is timely.  I’m also always happy to see new books aimed at the more experienced Python programmer in a time when the rapid (and very welcome) growth in the adoption of Python has led to the recent publication of a large number of beginners’ books.

To get the most out of this book, a knowledge of Python is expected and a working knowledge of Javascript and Django highly recommended.  The author also makes occasional (and perhaps inevitable) comparisons between Javascript and the Java language in the first couple of chapters, however a working knowledge of Java is definitely not needed.

The first chapter covers Python and Javascript.  As a Django/jQuery developer you’ll be using both languages and the author provides some interesting comparisons between the two.  The author is also quite candid and realistic about the weaknesses of Javascript and its cross-browser incompatibilities whilst carefully highlighting its strengths:  “If you can figure out why Python is a good language, you can figure out why JavaScript is a good language.”

The second chapter gets stuck into the basics of jQuery and the constructs which simplify the implementation of Ajax.  The third chapter then dives into Django with a tour of Django validation and a detailed discussion of validation in general.  The remainder of the book builds a reasonably large web application with each chapter pulling together a good number of disparate features you’d want to provide in any self-respecting Web 2.0 application.  Autocompletion, form validation, server-side validation, client-side and server-side search and login handling are all described and integrated into the application.  Even the creation of a “favicon.ico” is mentioned to put a company logo on your users’ web browser tabs and make them look distinctive.

It quickly became apparent that this book  is not a regurgitation of “the same old stuff”, rather it makes the effort not only to show you what to do, but also to discuss why you do something in a particular way and how you can improve on it, leaving the reader with a deeper understanding.  For example, the book is quite happy to extend the provided Django classes where they fall short, and show validation of more unusual types such as GPS coordinates not natively supported by Django.  Another example is the book’s excellent treatment of validation discussing cultural awareness and the suggestion that a “less is more” approach to validation can sometimes make sense.

Apart from a couple of typos here and there (which are possibly restricted to my electronic copy), a minor annoyance is what I felt to be a rather unorthodox Javascript formatting style.  For example:

set: function(newValue)
   var value = parseInt(newValue.toString());
   if (isNaN(value))
       return false;
       field = value;
       return true;

It’s quite possible again that this is a formatting issue restricted to my electronic copy (and I’ll investigate and update this review accordingly).  I also acknowledge that you can never please everyone with your coding style and layout!

The book stops short of helping you organise the inevitable growing mass of Javascript code, a difficult but increasingly important topic.  A little information around the modularisation of Javascript files or strategies and libraries for implementing MVC in client side code would have gone a long way.  Another aspect of the book which is notably glossed over is the topic of testing.  Testing can be hard, and testing web applications can be very hard, particularly those which rely on a lot of Javascript.  Admittedly this isn’t a book about testing, but implementing tests is a very important part of a developer’s life and a section or chapter setting the reader on the right path would have been welcome.

There are several parts of the book which deserve a special mention, however Chapter 11 particularly stands out.  The topic of usability is one often brushed over in technical books in favour of delivering more how-to’s and code examples.  The author devoted an entire chapter to usability, a chapter which I can only hope the authors of many web applications I’ve used might one day read.

I find it hard to characterise the author’s style of writing but I’d probably describe it as intellectual bordering on philosophical with a colourful vocabulary, a style which I enjoy but might not be to everyone’s taste.  An amusing example of the intellectual nature of the book can be found in Chapter 2: “Prototypal inheritance is more like the evolutionary picture of single-celled organisms that can mutate, reproduce asexually by cell division, and pass on (accumulated) mutations when they divide.”  I actually found this an interesting and useful analogy however it’s probably a little hard to relate to unless you remember your school biology!

In summary, I like this book.  I like the the fact that it’s filled with gems of information you won’t easily find online.  I like the colourful language and the interesting discussion around the concepts the author is conveying.  Most importantly, this book is written by someone who has clearly developed real web applications.  If you’re someone merely looking to get cracking on a project using Django and jQuery in the shortest time possible, then this book might disappoint.  But then again, the online tutorials and references are there to get you started and this book can take over where they leave off.

Finally, the author strikes me as someone both interesting and accomplished and I look forward to reading other books he might have in the works.

Cracks on the surface

The recent freeze and thaw of the canal beside where I live has produced a beautiful natural phenomenon.  Cracks in the surface ice reminiscent of neurons with pronounced dendrites have appeared in random locations.  Stars in the night sky also spring to mind:



The Circles of Satisfaction

What motivates us to get a job?  The instinctive answer for many might be: “To earn money!”  And what motivates us to stay in that job?  A member of the developed world might then pause for thought and mutter enlightened words such as “fulfilment” and “sense of worth”.

I’ve been thinking for some time about the factors that contribute to job satisfaction.  More specifically, I’m interested in why people stay in their jobs and at what point they decide to move on.  There are seemingly countless factors to consider, including money earned, working hours, length and ease of commute, boss, colleagues, being challenged etc. etc.  Each of these factors contributes variably to whether you stay or go.

In an attempt to better understand these factors and their influence on decision making, I’ve found that they can generally be placed into one of three categories:

  1. Remuneration.  Earning enough money to pay the bills and earning what you feel you are worth, whether it be with salary, commissions or payment in kind, for example, lavish trips or a generous expense account.
  2. Enjoyment.  Getting a kick out of doing what you do, for example, by being challenged either mentally or physically.  Getting to help others.  Enjoying the company and camaraderie of colleagues.  Getting on with your boss.
  3. Convenience.  Sensible commute.  Sensible working hours that don’t interfere with your non-work pursuits or family life.
Now we have our categories, let’s see how they influence us.  Enter The Circles of Satisfaction:

The Circles of Satisfaction. How satisfied are you in your job?

The formula is simple.  Add up the number of circles that apply to you:

  • If you score 3 out of 3, you’re very satisfied in your job and very lucky.
  • If you score 2 out of 3, you’re generally satisfied in your job and happy to stick with it.
  • If you score 1 out of 3, you’re probably looking for a job elsewhere.

Of course, if you score 0, you’re in real trouble!

If you’re an employer, try applying this formula to each of your staff.  You might be in for a surprise.

Now try this formula on yourself.  Are you in the right job?

PyWeek 11 – And the winner is …

PyWeek 11 has come to an end .  The judging is over and the winners have been announced.  The deserving winners are Universe Factory 11 as an individual entry with the game Mortimer the Lepidopterist and Super Effective 11 as a team entry with the game Trident Escape.

Mortimer the Lepidopterist

Trident Escape: The Dungeon of Destiny

Trident Escape: The Dungeon of Destiny

I made several interesting observations during the course of the contest.

Firstly, I’m no gamer, however that was clearly irrelevant to me as I thoroughly enjoyed the competition, the pressure of having to deliver a piece of software to a deadline (but not losing my job if I didn’t) and generally having free reign to hack with Python to produce a creative end product.  Not only that, but I was doing it in the knowledge that at least 39 teams of people would be playing with my creation.

Secondly, in telling my non-geek friends that I was entering this competition, I received all sorts of interest and support in what I was programming to a level I’d not experienced before.  It was both humbling and refreshing to be able to talk to my non-geek friends about what I was programming without a familiar glazed look descending on their faces.

Thirdly, I really enjoyed playing the other teams’ games and learnt a lot from doing so.  It was interesting to see the sheer variety of games and the creative thought that went into them.  It was also interesting to look at the code behind the games.  For me this was a real win and an affirmation that you learn most about coding from reading others’ code.

As mentioned previously, my entry was Voices Under Water and was written using the excellent pyglet and cocos2d libraries.  The game is based around a dolphin who has to catch life rings being thrown by a ship’s captain to save his crew from drowning.  It’s probably not the most exciting story, but I found myself writing the game then shoehorning the story onto it, and that was the best I could come up with!  Coming up with the name of the game was much easier.  My other half’s niece and her boyfriend are part of a band formerly called The Bacchae and more recently called Black Moth.  They kindly gave me permission to use one of their tracks which is fittingly called Voices Under Water as the backing music for the game.

Many thanks to the organisers and to the other teams for an enjoyable competition!

Python Northwest Returns

Just under a year ago a group of like-minded people in the Northwest of England with excellent taste in programming language got together for Python Northwest.  The plan is get together again this month.  Whether you’re a beginner Pythoneer or a seasoned Pythonista, or if you just want an excuse to go to the pub, then this meeting is for you!

Details are as follows:

  • When: Thursday 19th August 2010, 6pm
  • Where: Rain Bar, Manchester:
  • What: A social meet to chat about stuff we’ve found interesting / useful / fun with Python recently.  Topics likely to include games, robots, web programming, GUIs, parallel processing, audio generation, tips and tricks, and just about anything heard, said or done at the recent Europython conference.
  • Contact:

Building on the well attended and fun meetup organised by Michael Sparks last year, the hope is that Python Northwest will continue to meet every third Thursday of the month starting with social meets then alternating between social meets, technical meets and perhaps coding sessions.

Please forward, tweet and dent this to anyone or anylist you think might be interested, then email to say you’re coming along!

See you there …

Next »