OU blog

Personal Blogs

David Pennington

A hard 3rd week but a bit of realisation

Visible to anyone in the world

I have not found this third week particularly easy. I found that Notebook 04.5 particularly time consuming. I am not sure quite where the authors of the course got their timings from but I thought that the following was a bit optimistic:

"Activity 4.5 Notebook - 30 minutes"! At the end, it presents you with a list of tasks:

  • a) Show a count of the number of sales records for each District.
  • b) Show a count of the number of sales records for each Team in each District, including the Team and District margin totals.
  • c) Show the total sales value for each Team in each District summed over the year.
  • d) Show the total sales value for each Team Member in each District over the year, showing the District and Team member margin totals. (Remember you need the team name and salesperson name to identify each person uniquely.)
  • e) Show a bar chart of the number of sales each month. 
  • f) Show a bar chart of the total sales each month.
  • g) Show a scatter plot showing the Item Cost v. the number of Units in each record.
  • h) Add a Season column to the DataFrame. For each sale record, the value for Season will be derived from the month: (11,12,1) are Winter, (2,3,4) are Spring, (5,6,7) are Summer, (8,9,10) are Autumn. From the sales in each Season calculate the number, average, maximum, minimum and total sale amount over the season (that is, from all the sales records grouped by season report the number of records, and the average, maximum, minimum and total sales amounts).

These would prove to take me 1 1/2 hours on their own and I never did finish so quite where the 30 minutes for the whole notebook came from, I have no idea. Perhaps one of the course authors timed themselves? Anyway, I think that you would need to be very adept at Python and pandas to achieve the time. 

I left that notebook and tackled the next one - about Regular Expressions. I found this not quite so difficult but it did require some careful thinking. By this time, I was getting quite depressed about my chances of even getting to do TMA01, let alone complete it and continue. Fortunately, there was a post on the forum which set me back on the path of confidence (well - a bit). Someone mentioned that there wasn't an exam at the end so we had no need to have everything welded into our brains and that we could manage throughout by referring back to the course notes. A sign of understanding and relief was heard in my household.

On that basis, I tackled the first part of TMA01 and found that I could manage quite well! So, onward and upwards, as the saying goes.

I have been writing successful software for the last 35 years - some of it in mission critical situations such as bank currency trading rooms and so on. This has been done in Basic, which was taught to me by the OU in M251 An algorithmic approach to computing (in 1977), in UCSD Pascal (which was the OU's next teaching language and, finally, Smalltalk - which was the OU's third teaching language (replaced by Java and now Python to some extent). In all that time I have relied heavily on having documentation to hand as I have never managed to learn by rote all of the syntax of these languages. As an aside, Smalltalk (like pandas) has a very easy syntax but an extremely rich library so I spend some time regularly looking up stuff.

The upshot is, I think, that I should assume that I will do the same with Python, pandas and Regex and not try and have it all in my brain. I have one day left to complete week 4 to maintain my one week buffer so it is eyes down tomorrow for a good stint.

One last comment. Last week, I signed up for TM354 - Software Engineering, which starts in October. I have to say that those who know me from my development background expressed opinions that this would be quite boring given my CV. I felt that it would be a reasonable step to the final project course (TM470). However, it turns out that it has an examination. Ignore what I said above as I would be quite happy to sit this if it wasn't for my stupid arthritis and the problems it brings with continuity of concentration. As a result, I cancelled the application and signed up for TM352 - Web, mobile and cloud technologies. Firstly, this doesn't have an exam component but also it ties in very nicely with my thoughts on a project for TM470. More on this later.

Permalink Add your comment
Share post
David Pennington

Week One is nearly over

Visible to anyone in the world

I had planned to be well ahead by now but moving apartments put a stop to that. As it is, I have managed to get through to the end of week 2 and have the first ICMA (computer marked assignment) nearly completed. So far I have answered 4 questions correctly and one question that needed a second go. As I have to score 30% in five of the seven ICMAs I am quite pleased.

First reactions? Well, the Python bits are easy. Programming is what I do and the course is well presented through the iPython notebooks. I have had a few issues with data paths and, although I seem to have problems that others aren't getting, I am able to work my way around them. I don't seem to be able to make a CSV/JSON combination that works with CSVLint. My JSON description file won't be recognised by CSVLint. I have tried getting it through JSONLint but I can't even do that. So, that is in abeyance for now. I am having more difficulty with the theoretical parts but then I always thought that I would. It is, after all, 35 years since I have done any studying and my arthritis gives me issues with concentration. Funnily enough, I have no problem concentrating when I am coding. I think that I regard issues there as opportunities rather than as problems and I can keep going. Reading theoretical descriptions - I don't find that as gripping - so I have to work harder at it.

Reading the course description of databases has caused me to go back and think about the databases that I have worked with over the years. It is quite an interesting list.

  1. Linked Lists - I wrote my first database software back in 1980 when I created a Trading Room Front Office package using North Star Basic on a NS Horizon. For this, I wrote software for a series of linked lists that held transactions, exchange rates, dates, etc. all with an active re-use of deleted data spaces. The main problem with this was the fixed data widths.
  2. More Linked Lists. When I retired from the City and started my own software company we switched to UCSD Pascal and a complete re-write of the system. The product was called "Integrated Dealer Support System" (IDSS). To ensure that the database was robust, I got a guy called Mark Woodman to write the linked list code for me. At the time, he was an Open University lecturer (he is now a Professor at Middlesex University).
  3. In 1990, I switched to Visual Smalltalk (VSE) from Digitalk. With this, I wrote a Barrister support package based firstly on VOSS from LogicArts and then using Tensegrity from Polymorphic. These are/were Object Oriented Databases (OODB) that were integrated into the Smalltalk environment.  I went on to incorporate Tensegrity into my Smalltalk based Trading System which was called Powerdesk Trader.
  4. In later years, I have mostly written software for my own use. Between 2004 and 2012, I owned and ran a shop with my wife and daughter. This shop had a very active web site which, eventually when we closed the physical shop, became our main means of transacting business. The web software was based around a database of my own devising. Built using IBM's (latterly Instantiations) Visual Age Smaltalk - VAST - this utilised the built-in high speed directory system within Windows by having individual directories for all of the main database elements - products, users, sales, etc.  Within these directories I used VASTs own object dumper and loader mechanisms to save the various objects directly into their relevant directories with the file names providing the indexing. This worked remarkably well with the performance of the web site matching that of those with much more sophisticated (and expensive) systems.
  5. More recently, I have been building a freight car routing system for my US Outline model railroad. This utilises CSV files for its data. This option allows me to make changes to the data without having to write a lot of data management screens. For instance,when I purchase a new freight car, I can pull up the cars.csv file and add the new details within Excel.
  6. Finally, my serious programming has been for a US based insurance company where I my most recent project was to develop a insurance premium calculator based on normalising risk data for the clients. This gets its data from an MS SqlServer RDBMS.

Wow, that's a lot of variation through the years. It will be interesting to see how I really do cope with all the theoretical stuff, given that I have spent 35 years playing with all of the above!

Permalink Add your comment
Share post
David Pennington

The course is getting closer

Visible to anyone in the world
Edited by David Pennington, Thursday, 14 Jan 2016, 19:58

Getting closer meant that I had to get more serious about learning Python. 

I run a web and e-mail server from home. The e-mail server is for the family domain and there are three web sites that are running on the machine as well. I thought that I had put together a reliable setup when I  purchased a brand new Lenovo desktop box running Windows 8 (which was fairly quickly upgraded to Windows 10). However, the box freezes occasionally. I can't find any reason for this so I just have to manage the situation. I find the the Pingdom service, which is supposed to e-mail me when my server goes down isn't as reliable as I need.

I was casting around for another program to write in Python to extend my knowledge of the language so I thought that I would write my own Ping software. Now a ping is something that gets sent to a web address and reports back if the server at that address responds or not. What my software had to do was to regularly connect to the server and, if the server failed to respond, send me an e-mail. There was a few problems with me doing this in Python.

  1. I had no idea how to connect to a web server
  2. I had no idea how to send an e-mail
  3. I had no idea how to log these actions

So, this was going to test my ability to learn the inner details of Python. It was actually easier than I thought. Python has a rich set of libraries so I included the following in my program:

import smtplib
import requests
import time
import configparser
import os
These gave me everything that I needed. I used these libraries and very quickly I had my web checker program running. It runs in the background as a script on my iMac and has now been running for a few weeks without incident. It has shown me how useful Python can be. It would have been a good bit more complicated to do this simple task in Smalltalk - but then there are many things that I have done in Smalltalk that would be nigh on impossible in Python so, whilst I am pleased that I now know how to code in Python, I won't be giving up on Smalltalk anytime soon!

My next progression towards the course is a giant backward step. We have decided to move apartments and the move takes place on 23rd January. We are only moving from one floor to another (the new apartment is much bigger than the existing one) but, for various reasons, we are to lose our broadband internet connection for about 10 days - which covers the date of the start of the course! I am hoping that I can use my iPhone as a router for my iMac in the meantime. As we have a nice 4G signal here, that shouldn't be a hardship.

Lastly, I have quite severe Arthritis in a lot of my body so I have registered, through the OU, as disabled. Following an assessment of my problems, I have been awarded a grant that will provide me with equipment that will help me in my studies. I have difficulty sitting for too long in one position and find concentrating for long periods a trial due to pain levels.  Yesterday, I had a visit from a representative of an Ergonomics company who has carried out an assessment for a new desk, chair and reading aids. It seems that I am to get a desk that is electrically height adjustable, a fully configurable chair, an iPad holding device and a footrest. All of this is designed to get me into the best possible position for sitting at my iMac for extended periods. It seems to take about 6 weeks for this to happen but it does mean that, soon after the course starts, I will be able to get on with more success. My existing hobby room is way to small to take the new desk along with my other stuff so it is good that I am moving to a bigger apartment as the 2nd bedroom in that one is substantially larger than now. I might even have room for a decent model railway - at last!!!

Permalink Add your comment
Share post
David Pennington

New blog post

Visible to anyone in the world
Edited by David Pennington, Wednesday, 23 Mar 2016, 19:11

As mentioned, I am a newbie to Python. I was concerned about learning it because of my experience with Ruby on Rails some years ago. When I tackled Ruby, I kept getting annoyed because most of the stuff was so complicated in comparison with Smalltalk that I wondered why anyone would bother. Along the way, I got caught up in its constant automatic update of versions and finally threw it away. On first glance, I had a similar impression of Python but I had no choice but to get to grips with it if I was to make a good fist of the up-coming course.

I set myself a timetable of 8 hours a week to study as this got me into the right frame of mind that will be needed for my OU course. I then set myself a project to recreate my "Let's learn Latin" web program in Python. The plan included three steps.

  1. To write a Python program to test vocabulary.
  2. To add the Pandas library to it and start to do some statistical analysis of the results. (Pandas is a library that includes lots of stats stuff).
  3. Convert it to be a web program.

I got as far as midway through 2 when I came up with a better plan. 

Problem

I run an e-mail and web server from home. The e-mail server provides a domain for all of the family to have simple e-mail addresses. Mine, for instance, is david@xxxweb.com. Recently, I replaced the server with a new Lenovo machine that has now updated itself to Windows 10. Being a long time Mac man (since 1990!), I don't much like this but I can't get the e-mail moved to the Mac as we have some much history in the Windows program that we use (Magic Winmail). The problem is that the server randomly freezes and I can't find any reason. I have got so irritated that I have considered going back to Windows XP. I don't always notice that the server has frozen so, sometimes, it is down for a couple of hours. I have a Pingdom account but that sends to my own e-mail address which is useless but, since Pingdom changed their web site, I can't seem to find where to go to change the address. 

Answer

I have written a headless Python program that loops around every 20 seconds and tests that one of the web sites on the server is responding. If it isn't then it sends an e-mail to my Outlook mail account, which gets forwarded to my iCloud mail. Along the way, it logs its actions and responses to a logfile on the Mac. This took about 7 hours to write and works perfectly.

Assessment

Python has proved to be very understandable, once I got the idea of line indentation and its use of commas. The main thing that I like is the depth of its available libraries. I have the following libraries in my program:

import smtplib
import requests
import time
import configparser
import os
These provide simple access to e-mail sending, html gets, delay management, ini file and text file access. These significantly reduced my development time. I am very impressed. I now feel that I have come to grips with the language and, although I am a long way from being an expert, I feel that I can cope with anything that comes along. The code can be seen HERE.

I am now going back to the vocabulary tester to complete the statistical side.

Permalink Add your comment
Share post
David Pennington

Getting down to the prep.

Visible to anyone in the world
Edited by David Pennington, Tuesday, 8 Dec 2015, 11:01

I have been writing Smalltalk software since about 1990ish, firstly with VSE and then, from around 1995, IBM VisualAge(now Instantiations). This means that I am very embedded in the world of Object Oriented Software development (OO) and with the standard Smalltalk paradigm where everything is an object. Part of that experience means that I think in objects and write new classes for everything. This isn't always the case for people new to OO where they tend to write sequential code until they are forced into making a class. As an example, I used to work in a large banking software company where I was in charge of development of a reporting system that was being written in Java. This was the first Java development for the team and I was the only person that had really been exposed to OO (I am ignoring the fact the programmers had all been using C++ but I am guessing that they still basically wrote C code).

I was asking one of the senior guys (he had been in the company some 15 years) how it was getting on and his comment was "Glyn (one of the senior developers) tells me that I have to create more classes than currently. I can't see why. The software works, doesn't it?". 

OK, back to the present. The course that I am taking involves using the Python programming language for a lot of the data manipulation. There is a Python package called Pandas that has a huge library of tools for this. I did a three week on line course in Data Manipulation which gave an introduction into Pandas but felt that I really needed to get to grips with Python before the course starts at the end of January. I was mainly concerned with the way that OO works in Python as it looked very easy to write sequential code and ignore OO altogether.

Recently, I have been getting back into the groove of studying for 8 hours, or so, a week. If I don't get into the habit now then it will be difficult when the time comes. Hence, I have been carrying out a few tasks. These have included a course on Calculus, the Data Manipulation course mentioned above and a home study course in Latin (which recently morphed into Dutch). The calculus course was very trivial and I should have kept working through the home study book that I got for my birthday back in March. The data course was very good. The Latin/Dutch was hard because I have forgotten how to sit and learn vocabulary ready for the next session (shades of French and Latin back in my school days so many years ago!). I decided to write a testing program for the vocabulary. I did this in Smalltalk and it works very well as a web development.

Now - to learn Python. Why not recreate the vocabulary program in Python. Admittedly, it will be a command line program so nowhere near the Smalltalk one for presentation but functionality is everything in Python, rather than making nice windows etc. I spent the last 4 of my 2 hour sessions slowly working through the steps and ensuring that the Python code was fully object oriented. Well, yesterday, I was able to go through 10 questions of Dutch words and getting feedback on the right and wrong answers. It still has a way to go but it has proved to me that I "can" do this Python thing. I still have 7 weeks until the course starts so I still have plenty of time to get proficient.

The current Python code can be seen HERE. I will update it as I make further changes.

Lastly, the really good news is that I have been accepted for a Disabled Students Allowance with may provide me with a new, ergonomic, chair and desk that I can sit at for longer then 45 minutes at a time. I will report back on that one.

Permalink Add your comment
Share post

This blog might contain posts that are only visible to logged-in users, or where only logged-in users can comment. If you have an account on the system, please log in for full access.

Total visits to this blog: 34380