Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Bellringing and Programming and Objects and Perl

For the second time this year (and it's only the second month), I find that I have a keen bell-ringer on my programming course ... he's off each evening to meet up with fellow bell-ringers in church towers in Wiltshire, and having a really good time outside course hours as well as during the day. I understand that there are a substantial number of excellent sets of bells (I know that the word "set" is wrong) in this area, and I listen in some awe to the complexity described in ringing sequences - how do you get from a string like x16x36x36 to a set of results like:
1 2 3 4 5 6
2 1 4 3 6 5
2 4 1 6 3 5
4 2 6 1 5 3
2 4 6 5 1 3
4 2 5 6 3 1
2 4 5 3 6 1

With so many questions like this one - "how do I get from 'A' to 'B'" - you only need one expert to tell you how to do it, write down and test the algorithm, and then anyone who can provide inputs and read outputs can use the algorithm. In Object Oriented terms, this "hiding information within" approach is known by the term "encapsulation".

Helped by 'George' and 'Sandra', I've learn a little about ringing in the last weeks and yesterday George and I put together a sample program to ring some parts of bell changes, using Perl. Not exactly what he'll be using Perl for at work, but a parallel through which he can practise and learn further. Here's some of the code:

use bells;

push @method,new bells("Plain Bob",8);
push @method,new bells("Grandsire Triples",7);
push @method,new bells("St Clements",6);

$method[0]->setplace("x18x18"); # etc ...
$method[1]->setplace("3.1.7.1.7"); # etc ...
$method[2]->setplace("x16x36x36"); # etc ...


We've set up three methods of ringing, by name and by the number of bells involved in the changes. We've then called a method called "setplace" to define how the changes happen in place notation. Let's then ring the changes:

foreach $curr_method(@method) {

Printing out a header for each set of changes, and getting back an "action list" of what we need to apply:

@chlist = $curr_method->getchanges();
$method_name = $curr_method->getname();
print "Ringing $method_name\n";
@order =$curr_method->getcurrent();
print "@order\n";


And then actually ringing the changes are reporting the order of the bells.

foreach $chan (@chlist) {
$curr_method->change($chan);
@order =$curr_method->getcurrent();
print "@order\n";
}
}


Yes, that's all there is in my main application! The code that took us a while to work out which interprets the place notation strings and applies it to the rings of bells is all hidden within the file bells.pm which we called in at the top. The typical user doesn't need to know how it works. All they want to do is to run a program like the one above and read:

Ringing Plain Bob
1 2 3 4 5 6 7 8
2 1 4 3 6 5 8 7
2 4 1 6 3 8 5 7
4 2 6 1 8 3 7 5
4 6 2 8 1 7 3 5
Ringing Grandsire Triples
1 2 3 4 5 6 7
2 1 3 5 4 7 6
2 3 1 4 5 6 7
3 2 4 1 6 5 7
3 4 2 6 1 7 5
4 3 6 2 7 1 5
Ringing St Clements
1 2 3 4 5 6
2 1 4 3 6 5
2 4 1 6 3 5
4 2 6 1 5 3
2 4 6 5 1 3
4 2 5 6 3 1
2 4 5 3 6 1

I HAVE placed the bells.pm on our website if you would like a look - there's a link to it from our Object Oriented Design - Individual Object module as this complex field has proven to be such a great example of the use of encapsulation, even on a quite small project.


(written 2005-02-25, updated 2008-05-16)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
Q906 - Object Orientation and General technical topics - Object Orientation: Individual Objects
  [507] Introduction to Object Oriented Programming - (2005-11-27)
  [1543] Learning Object Oriented Principles (and perhaps Java) - (2008-02-17)
  [1864] Object Oriented Perl - First Steps - (2008-11-01)
  [1925] Introduction to Object Oriented Programming - (2008-12-06)
  [2171] Cleaning up redundant objects - (2009-05-11)
  [2173] Basic OO principles - (2009-05-11)
  [2393] A first demonstration of OO, including polymorphism - (2009-09-04)
  [2651] Calculation within objects - early, last minute, or cached? - (2010-02-26)
  [3436] Moving from scripting to Object Orientation in Python - (2011-09-13)
  [3721] Naming blocks of code, structures and Object Orientation - efficient coding in manageable chunks - (2012-05-06)
  [4021] Spike solution, refactored and reusable, Python - Example - (2013-02-28)
  [4448] What is the difference between a function and a method? - (2015-03-04)
  [4591] From single block to structure and object oriented programming - (2015-12-02)
  [4650] Why populate object with values as you construct them? - (2016-02-18)

Q110 - Object Orientation and General technical topics - Programming Algorithms
  [202] Searching for numbers - (2005-02-04)
  [642] How similar are two words - (2006-03-11)
  [1157] Speed Networking - a great evening and how we arranged it - (2007-04-21)
  [1187] Updating a page strictly every minute (PHP, Perl) - (2007-05-14)
  [1391] Ordnance Survey Grid Reference to Latitude / Longitude - (2007-10-14)
  [1840] Validating Credit Card Numbers - (2008-10-14)
  [1949] Nuclear Physics comes to our web site - (2008-12-17)
  [2189] Matching disparate referencing systems (MediaWiki, PHP, also Tcl) - (2009-05-19)
  [2259] Grouping rows for a summary report - MySQL and PHP - (2009-06-27)
  [2509] A life lesson from the accuracy of numbers in Excel and Lua - (2009-11-21)
  [2586] And and Or illustrated by locks - (2010-01-17)
  [2617] Comparing floating point numbers - a word of caution and a solution - (2010-02-01)
  [2894] Sorting people by their names - (2010-07-29)
  [2951] Lots of way of converting 3 letter month abbreviations to numbers - (2010-09-10)
  [2993] Arrays v Lists - what is the difference, why use one or the other - (2010-10-10)
  [3042] Least Common Ancestor - what is it, and a Least Common Ancestor algorithm implemented in Perl - (2010-11-11)
  [3072] Finding elements common to many lists / arrays - (2010-11-26)
  [3093] How many toilet rolls - hotel inventory and useage - (2010-12-18)
  [3102] AND and OR operators - what is the difference between logical and bitwise varieties? - (2010-12-24)
  [3451] Why would you want to use a Perl hash? - (2011-09-20)
  [3620] Finding the total, average, minimum and maximum in a program - (2012-02-22)
  [3662] Finding all the unique lines in a file, using Python or Perl - (2012-03-20)
  [4325] Learning to program - what are algorithms and design patterns? - (2014-11-22)
  [4401] Selecting RECENT and POPULAR news and trends for your web site users - (2015-01-19)
  [4402] Finding sum, minimum, maximum and average in Python (and Ruby) - (2015-01-19)
  [4410] A good example of recursion - a real use in Python - (2015-02-01)
  [4652] Testing new algorithms in PHP - (2016-02-20)
  [4656] Identifying the first and last records in a sequence - (2016-02-26)
  [4707] Some gems from an introduction to Python - (2016-10-29)

P218 - Perl - More Objects
  [246] When to bless a Perl variable - (2005-03-15)
  [531] Packages in packages in Perl - (2005-12-16)
  [588] Changing @INC - where Perl loads its modules - (2006-02-02)
  [592] NOT Gone phishing - (2006-02-05)
  [656] Think about your design even if you don't use full UML - (2006-03-24)
  [831] Comparison of Object Oriented Philosophy - Python, Java, C++, Perl - (2006-08-13)
  [930] -> , >= and => in Perl - (2006-11-18)
  [1217] What are factory and singleton classes? - (2007-06-04)
  [1320] Perl for Larger Projects - Object Oriented Perl - (2007-08-25)
  [1435] Object Oriented Programming in Perl - Course - (2007-11-18)
  [1664] Example of OO in Perl - (2008-06-03)
  [1665] Factory method example - Perl - (2008-06-04)
  [1819] Calling base class constructors - (2008-10-03)
  [2427] Operator overloading - redefining addition and other Perl tricks - (2009-09-27)
  [2717] The Multiple Inheritance Conundrum, interfaces and mixins - (2010-04-11)
  [2811] Igloos melt in the summer, but houses do not - (2010-06-15)
  [2876] Different perl examples - some corners I rarely explore - (2010-07-18)
  [2972] Some more advanced Perl examples from a recent course - (2010-09-27)
  [3097] Making Perl class definitions more conventional and shorter - (2010-12-20)
  [3098] Learning Object Orientation in Perl through bananas and perhaps Moose - (2010-12-21)
  [3377] What do I mean when I add things in Perl? - (2011-08-02)
  [3581] Perl - calls to methods that use => - what do they mean? - (2012-01-16)
  [3941] Building an object based on another object in Perl - (2012-12-03)
  [4096] Perl design patterns example - (2013-05-20)
  [4098] Using object orientation for non-physical objects - (2013-05-22)
  [4356] Object factories in C++, Python, PHP and Perl - (2014-12-19)
  [4366] Changing what operators do on objects - a comparison across different programming languages - (2014-12-26)

P213 - Perl - Creating your own Classes
  [975] Answering ALL the delegate's Perl questions - (2006-12-09)
  [983] Blessing in Perl / Member variable in Ruby - (2006-12-14)
  [2169] When should I use OO techniques? - (2009-05-11)
  [2834] Teaching examples in Perl - third and final part - (2010-06-27)
  [2877] Further more advanced Perl examples - (2010-07-19)
  [2969] What does blessing a variable in Perl mean? - (2010-09-24)
  [3059] Object Orientation in an hour and other Perl Lectures - (2010-11-18)
  [3833] Learning to use existing classes in Perl - (2012-08-10)
  [4607] Classes and object - first steps in Perl 6 - (2016-01-02)


Back to
Growing our systems
Previous and next
or
Horse's mouth home
Forward to
Beard Justification
Some other Articles
Feedback as lifeblood
Course sizes - beware of marketing statistics
A fortunate accident
Beard Justification
Bellringing and Programming and Objects and Perl
Growing our systems
10 years and counting
YOUR application and YOUR data
There is a function in PHP to do that
Who are all these visitors?
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2021: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/227_Bell ... -Perl.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb