
When it comes to producing new examples for a course, where better to look than close to home? Yesterday, I was looking for an example to use when I was covering
object design in Python and I hit upon working with taps and the water suppy to them.

Looking around, we have quite a few taps here; several of them are in the training centre part of the building (the first two that I've pictured) and others are elsewhere.

The taps differ a little - some are mixer taps, others (such as the outside tap) are cold only,and the tap in the kitchen is a spectacular tap that I've christened to be a "supertap". Together, these make a great example of a base class and the ability to define inheritance.

Our sample application went further. We defined connection objects which describe which mains supply each tap is connected to in the building, and we then define a maximum flow through that connection. This allows our python application to know when there isn't enough capacity available when someone tries to turn a tap on.

If you're writing code in an object oriented language such as
Python, it's important that you think carefully about the objects that you're dealing with and specify the classes and methods that you'll be using as carefully as possible at the start. On many of our courses, we include modules on
object oriented design in order to help you save time in the long term by getting tings right from the start.

It's only when you start working with classes in this way that you realise just what a powerful resource they are ...
(written 2005-03-05 08:26:34)
Associated topics are indexed under
Q907 - Object Orientation and General technical topics - Object Orientation: Design TechniquesY301 - Python - Class Interaction - an example
Some other Articles
Conventional restraints removedWhat and why for the epochDifficulties with a trolleyCrossfertilisation, PHP to PythonTapping in on resourcesPreparation for a day's workHow to get the best from your supplierGiving customers best valueDiverse activitiesFeedback as lifeblood