blog
MST121/M263

This is the blog that I kept during blocks 1 and 2 of M263 & MST121. October 2008 to February 2009.

The second part is now available.

2008-09-26

Start as you mean to go on

Due to [various] circumstances I registered really late for my starter courses for my computing and mathematical sciences degree, but it was purely stupidity that made me not return the registration agreement for the building blocks of software. So at the moment things are a bit up in the air. A call to the OU help desk was reassuring but worry is still my companion.

The maths course site went live this evening, and I’m going to check it out fully in a minute. It does look as if we have to submit a CMA by next Friday. That can’t be right, surely?

Just what, exactly, have I let myself in for?

2008-10-05

Getting started

Well I’m finally signed up for both courses, the websites are live and there are two new icons on my first class desktop full of unread posts. All the course materials haven’t arrived yet so I don’t, fully, know what I’ve let myself in for. But from looking at the online materials and from what I’ve got so far I feel that the shadow of work overload again falls on our bold hero.

I’m going to refer to MST121 as the maths course and M263 as the software course.

I spent Friday afternoon working my way through the practice maths TMA and in an odd way I enjoyed it. Things that I’d thought were long forgotten started coming back to me. It’s a tribute to the hard work of Miss Harkness [my maths teacher] that over thirty years later I can still dredge this stuff up—it’s certainly no tribute to any work I did. I was [and still am] a lazy wee bugger and would have skipped the work if she hadn’t made that impossible. Thank you Miss H.

Looking through the maths course I can’t see anything that I haven’t at least looked at before, so while I may be rusty, I [think] that I should be ok with this one.

It may be different with the software course. From some online perusal and a look at some of the threads on first class I can see that we’re dealing with concepts unfamiliar to a slap dash script-kiddie like me [like rigour]. We’ll wait and see with this one—I’ll have a better idea when the paper copies arrive.

My first tutorial

Was yesterday. I was a wee bit nervous—it felt a bit like my first day at a new school. But it was all good. Everybody was friendly and the tutors were very good; they managed to get through all the dull admin stuff in an amusing fashion and the little bit of maths we did cleared up a few of my misconceptions.

I was a bit unsure as to whether I’d go to tutorials—at bottom I like to learn by messing around on my own, but I think that I’ll try to get along to as many as my work commitments allow. If only because it was quite fun and it made me feel a bit like a real student again.

Getting organized

I think that I’ll need to develop a better study regime for these courses—the tt style work hard/read blogs/do nothing/last minute panic approach isn’t going to cut it this time methinks. The plan is to set aside some time every week where I sit at the kitchen table and do some work. This will, inevitably, not happen, but it is the plan. But these times will, alas, coincide with the occasions when my wife requires me to do something—so there is hope.

Anyway, the sun is shining so I’m off to listen to a CD of maths porn [as my wife has dubbed it] before cracking open a cold beer and watching Harry Potter.

2008-10-10

Two worrying thuds

Well as the delivery person knocked on the door and handed me the parcels that’s not strictly true. But two large boxes of books arrived this week, and they would have made a lot of noise if they’d landed on the floor, and that was only the first mailing. Worrying.

Actually I’m not too worried about the books, one of the things that I like about the OU is the books. What worries me more are the CDs and DVDs for the maths course. There is no way that my good lady wife is going to let me watch/listen to these while she’s within earshot. Which will mean that I’ll either to have to get up in the middle of the night, or I’ll have to go through them at work. Neither optimal. I’ll think of something, I hope.

The plan

Ah, the cunning plan neil. [I shall ignore the carpers].

Is to read through the books for a whole block quickly, then to work my way through the exercises while reading the relevant section more deeply. I also plan to set aside a certain amount of time for each section - which means, basically, that I’ll follow the study schedule this time. Of course, apart from the initial speed reading, this is how you’re supposed to do it.

My reasoning for the initial read-through is that I’ll get a feel for the block as a whole and I can identify where my weaknesses lie. Actually that’s I lie, I like reading and it will allow me to put off the hard slog of doing the exercises for a few days.

My feeling, however, is that it’s going to be important to develop some kind of a study regime. During the tts I got away without having one, and without doing [almost] any exercises at all only because I knew quite a bit about the subject. Now, while that’s still, mostly, the case for the initial blocks of these courses, future blocks are going to be built on a good understanding of the basics. And if I get into a regime I might stick to it when my inherent laziness takes to the front—i.e. when my initial excitement wears off.

Enjoying it?

Yes, but as mentioned above we are in the honeymoon part of the course. We’ll see how I feel when I don’t feel like working, I don’t understand or when the work begins to pile up.

It’s Friday night, I’m stuck at work, I’m now faced with uploading a whole load of pages [over a web interface on a slowish connection] and I have to work tomorrow. The course can’t ever be any worse than this!

2008-10-28

An extended holiday

Of sorts. I had a holiday from work [as in my employment rather than course work] last week, which meant sleeping fourteen hours a day, drinking too much, pulling a muscle due to inactivity and a break from the computer. Well I checked into first class every now and again of course. Which left me pretty much free to polish up my rusty maths and decimate a small rain forest in the process.

I wouldn’t have been free if my back had remained unstrained and the weather had been better—I’d have been in the garden all week. So getting to mess around with maths was all gain really.

Towards the end of the week I remarked to my wife that I, “hadn’t done so much maths in years”. Which was a stupid thing to say considering that for the next five or so years I’ll be doing even more. I guess it hasn’t quite sunk in that I’m doing a maths & computing degree yet.

And how’s that going?

The main thing that I’m noticing is that the pace seems a whole lot less frenetic than the tts, although I am working harder. Which seems like a paradox and may well be. I suppose the reason that I feel less pressure is that the courses are so much longer—if this were a tt we’d be a third of the way through by now instead of just starting.

I’ve been concentrating on the maths, partly because I’m enjoying messing around with equations and partly because I feel that I’m weaker there. And as we’re still concentrating on basic techniques, that we’ll use later in the course, time spent now will help later.

The maths is coming back to me, albeit rather slower than I’d like. Ideally it would just spring back into my head with no effort at all. But maths is something that you have to do, so that was never going to happen.

The TMAs

The first part of these for both courses are in, and I await the marks with interest.

That’s another major difference with these courses compared to the tts—tutor feedback. One of the major complaints on the tts was that you never really knew what you’d done wrong, or right come to that. It’ll be interesting to see how much this actually helps, a lot I’d have thought.

At this point I was going to review the course software, but I think I’ll mess around with it some more before giving you my inconsidered opinion. In fact I’m off to mess around with it now…

2008-11-12

It’s all gone horribly wrong

Well it hasn’t really, it just feels that way. I won’t bore you with the details but [in a nutshell] I’ve been: ill, forced to murder my dog, hacked off at work and ineffective at home. In an even shorter nutshell I haven’t been able to get anything done. Well that isn’t strictly true—I done a lot of maths stuff and I’ve been messing around with WorkPad [the computer course’s software] and to a lesser extent MathCad [ditto for maths]. So it’s now time to tell you what I think, but first…

That’s really odd

I periodically check what search terms are throwing up this site using Google’s webmaster tools. Usually there’s nothing very surprising—tt will usually have me in there someplace [not surprising given that nearly all the big H1 tags are neil’s tt’s]. But today something odd.

Now somewhere down this very page I said that my wife described the maths CD/DVDs as “maths porn”. Yes, you’ve guessed it this site came up when someone googled it. What type of deviant googles that? And, perhaps, even more germane what else is coming up in the search?

I don’t care to google it myself—and certainly not from my work computer, but I’ve a feeling that there’s going to remain a niggling curiosity about exactly what maths porn might be. Being as narrow-minded as the next Scot I can’t even begin to imagine. And given that I’ve mentioned the term another couple of times, if this isn’t just an abhorrent drunken one-off by a lonely professor then it’s likely to happen again. Oh dear.

The course software

I’m guessing that most OU courses come with software nowadays. So what’s on offer this time?

WorkPad

It’s a wee bit unfair to review this as if it were an actual working application—it has been developed to teach us about programme languages rather than as something that you’d use for real. So all I’ll say is that it’s pretty basic [no drag and drop]. Not that that’s too much a worry for me, I cut my programmer’s milk-teeth on AppleScript on OS8 - now that was basic.

Of real interest [to me] is that it’s built on JavaScript, an odd decision given that JavaScript tends to the functional style and the course language is imperative. It also throws up a few oddities: functions are first-class objects, you can use closures, but you can’t use anonymous functions et al. I could play around with it trying to find out exactly what you can and cannot do, but I’m going to try and resist the temptation, after all I’m not supposed to use it that way!

MathsCad

Now here is a beast of an entirely different ilk; fully featured high-power software. But not the most intuitive application ever written.

I haven’t even scratched the surface of what’s available, so all I’ll say is that if you’re a maths nut it’s worth a good chunk of the course fee to get your hands on this little baby; I’ve spent several happy hours messing around with [for instance] the graphing possibilities. Great stuff!

Why does the default font for Window’s applications always seem to be a God-awful 10 point Times? The first thing I always do is to change the default font. [And in MathsCad it doesn’t stick—I had to create a template.]

But as I said not the easiest of programmes to get your head around. Which is a shame because I think that with a few UI tweaks it could be made much nicer. For example we write 3a, meaning 3 times a, but in MathsCad you have to type 3*a. This is made worse by the fact that you can’t tell if you’ve mistyped just by looking type 3*a or 3a and you’ll see 3.a displayed. [There are ways round this but the default behaviour is poor.]

There are also a few subtleties. I’m a programmer [read script-kiddy], so I can see that when we are solving an equation the underlying algorithm is ‘brute force’. Which is why we have to provide a starting point and a range; but it’s easy to leave that out and it isn’t at all obvious what gone wrong, there has to be a way round that.

But, carping aside, all in all a great application.

As I play more I may try to put together a basic cheat-sheet.

Speaking of maths

I’d forgotten how much fun maths is, I’m so glad I decided to do it alongside computing.

2008-11-19

TMA away

Well I got my first [full] TMA posted off yesterday. That was for the maths course, the computer one is due on December 1st. Thoughts? Well not many really, apart from the fact that it was posted. Hard copy, dead tree stuff. But then I’m used to doing maths that way and I’d hate to have to use Word [or something] to do any maths. That sounds like a nightmare.

The computer one can be submitted electronically, they do give you an option of posting it, but given that you have to include some WorkPad files [as a .txt] and it is computing, who is going to do that?

But the main thing that I notice is that these are Tutor marked assignments. I must admit that I’m finding having a tutor, who you know, and who knows you, and who marks your work, a wee bit strange. I know that it is the norm in education; but it’s been so long since I’ve been a student [and I’ve been two years at the tts] that I feel… how do I feel? I suppose a bit too close to it. I’m used to the comforting distance that interaction via a machine gives. I’ll have to think about that—now that I write it, it sounds a bit odd.

Other stuff

Well I finally got round to some of this. I’ve been threatening [if that’s the right word] to do various things for a long time now and this Saturday I, finally, managed to get started on one of them.

I was at work of course, the type of let where I just have to be there, rather than do anything. [If I go away for even five minutes the building catches fire and I come back to people throwing themselves off the top floor—but nothing happens if I’m there]. So as Daz has done some brilliant new Sparkl stuff—it was time to build my new site. And, although I’ve used it before I was going to us Tony’s WebPage exclusively this time.

They did fine work, I’m not sure if I did.

Well it’s late

… And I have a school to lock up, so, I guess that will have to be all.

2008-11-23

At work again

It seems like I’m at work [as in my job] all the time recently—I’ve worked seven days on the trot and I don’t get a day off until next Saturday. Still it has allowed me to catch up with some of the things that I’ve meaning to get around to for some time. These would not be employment related things—we’re well behind there.

My TMA for the computer course is complete but unsubmitted. I don’t have to submit it until December 1st, I’ll probably submit it next weekend. Experience has led me not to rush these things; another student may find an error in the questions—it might even be me! And it’s easier to check your work after a period of time has elapsed. You tend to get stuck in a mindset when you’re doing TMAs [or CMAs] and, particularly with computing, this mindset can lead to error. Best to come at it fresh and without preconceptions.

This tosh

Now that the first TMAs have been [or are about to be] submitted it’s time to decide how this blog is going to be managed.

Well both courses are split into four blocks, and although they are a wee bit out of sync, it seems natural to divide this tosh into four parts, these parts corresponding to the four blocks. That will stop this page from becoming too long and will allow me to sum up my thoughts, feelings and experiences as we go along. Rather than at the end when time and alcohol will have blurred the raw edges.

I will do this splitting when I’ve received the results of both TMAs. That way I’ll know how I’m doing and, perhaps, this will lead to a better quality of inconsidered opinion.

But so far?

So far I’m enjoying both courses, more so the maths one. I thing this is down to the fact that I’m still pretty much in my comfort zone when it comes to the computer course. Looking ahead I can see that this will change—we are about to get into formal logic, recursion and proof. All good stuff no doubt but frightening to a scatterdash code dilettante like myself.

The maths course is also very well paced and put together, the geometry fits nicely with the algebra; a relationship which I didn’t understand when I was at school. In fact looking back there was quite a lot I didn’t understand but could do by rote.

I remember, as a spotty sixth year, going to Stirling University for a maths competition. The questions were put in such a way that you had to choose your own tools, no “use linear programming to…”. I was all at sea and answered precisely no questions. Couldn’t apply my knowledge. Hopefully this time things will be different, mathematical modeling and using maths practically are built right into the course from unit one.

So what to do with my Sunday at work?

First off I’ve got some exam desks to put away. I’ve already been doing this for a couple of hours [I’m writing this while I take a break]. Then there is more work type work that I will avoid. I feel like doing some JavaScript but I should do some more work on my new site.

In fact that’s what I’m going to do, after the damn desks.

2008-12-03

Position a

In the sense that both of my TMAs being submitted. In fact the maths one is already back [I did quite well]. So we are almost at the point where I can review the first blocks of both courses. Almost—but not quite.

The plan was, and is, to do the block reviews [and archive this trash] after I’ve been marked for that block. The rational is that if I, say get 70%, I’ll have a different view on the block than if I got 40%, or 90%. Although whether I’ll have anything original and incisive to say, whatever I get and whenever I choose to say it, is a moot point. But I’ll hold fast to the plan.

But…

I will say a wee bit about the maths course. From conversations that I’ve had, or listened to, at tutorials and threads that I’ve followed on first class there’s been a recurring theme—will we forget all this stuff? This chimes exactly with my own fears and experience. And I don’t think that this is a mere paranoia.

As a for instance, the night before last Saturday’s tutorial I dug out the B1 book [B1 is about series but features a lot of population modelling]. I’d worked through this book doing all the activities and exercises just a couple of weeks ago. I thought that I had a good handle on the whole thing. But a couple of weeks later everything was gone, the head was empty, I couldn’t remember a single thing. Well, it wasn’t quite that bad, as soon as I shoved a pencil in my hand and started messing around things started to come back to me.

And that has to be the trick: do lots of exercises, play around lots, invent your own problems, in short work hard. Mathematics is about doing, not reading. If you do many, many exercises your hand will remember and your brain will catch up.

This sounds like weird thinking, but I know from playing chess that your hand often “knows” what to do when your brain is all at sea. It why you can play reasonable games at really fast time controls. Which brings me to…

Tutorials

For me these have been a real help. The combination of mini-lectures, group work and the opportunity to ask questions have helped to clarify many things. Many things that I hadn’t realise needed clarifying. My tutors have also done a great job in offering a different approach to the material—if we were just working our way through the course book I think that they’d be a whole lot less worthwhile.

Now I realise that not all tutorials follow the same format, but I’ll go out on a limb and suggest that everyone can get something from them. Make every effort, and some sacrifices [I lose overtime] to attend. Apart from anything else they are great fun.

MathsCad

I’ve been avoiding messing around with this, but I must get down to it—there is a job for me here. I’ve messed around with many [too many] applications over the years and I really should get together a cheat sheet for this one. I’m not trying to suggest that I’m a computer guru but I do have some expertise in getting the best out of that recalcitrant app. I know this because people are always asking me to do computer type things for them.

[They always look at my feet, to see if they are made of clay, when the first thing that I do is to hit F1 to pull up the help menu.]

As an example: my tutor was showing us some MathsCad type stuff on Saturday and made the mistake of selecting an entire expression and deleting it rather than editing it. My hands knew what to do [see above]—ctrl-z, what he did was to close the worksheet without saving and re-opened it. I should have piped up but by the time that my brain had caught up and I’d realised what was happening the moment was lost.

But I should do something. That will be tomorrow sorted out then.

And then?

I feel the need of some soothing JavaScript. My life is getting a wee bit messy, thing are piling up. Now some people comfort eat, drink too much [although I’ll do this too] or indulge in some other destructive addictive behaviour. My ‘head mess’ of choice is some JavaScript.

So I’m going to try to do something that I’ve been meaning to do for a long time—make a completely accessible Google map. That will be Saturday [and the rest of the week].

2008-12-18

Block 1, for you the war is over

Yes, block 1 is now over for both courses. Which means that it’s time to archive this blog, start a new one and to write some words about how I fared.

The plan is to get all this done over the festive season. I foresee problems with this. For a start many other things need to be done over the festive season and I’m sure that we all know that Christmas involves a large amount of unwanted socialising that gets in the way of having fun. Then there’s the problem of seasonal excess—I’m already feeling sick from gorging my way through the biscuits and chocolates that people feel compelled to give me at this time of year. So we’ll see what pans out.

Looking ahead

I’m steadily working my way through block 2 on both courses without too much difficulty at the moment. My main problem is remembering what I’ve done when I return to the later. Things that I thought had penetrated turn out not to have. This is worrying as, from a quick squint, block 3 for both courses is when the going gets tough. And quickly.

The computer course starts to get much more advanced with formal logic and we start calculus in maths. I remember not liking calculus much when I did it at school and I’ve always had problems with logic. More work I’m afraid; I have to have a firm foundation to build on before we get to block 3.

MathCad

I did manage to get started on what will hopefully be the definitive guide to MathCad. At present it isn’t much more than making MathCad look a little nicer, but I’ll try to get round to some more helpful stuff soon.

Well best be off to do some of the many things that remain undone.

2009-01-06

Sod all done

As you can see. Everything promised in the last post has not occurred. True, I did suggest that there might be problems, but for absolutely nothing to have been done… that’s going some even for me. In my defence I offer up the following excuses:

  • I didn’t realize how tired I was. Two weeks of sleeping for over twelve hours a day has improved my condition to a ‘wee bit knackered’. [As my wee brother said: I may be evolving into a hibernating animal.]
  • It was the festive season; even a confirmed bah humbug like myself is expected to exhibit a wee bit of conviviality.
  • I did do quite a bit of maths stuff.
  • It was cold.
  • I was drunk.

All feeble I’ll own. But the complete lack of progress has led to a change of plan.

“Not another change of plan Neil!”, you cry. Yes, alas, another change of plan. But then there never really was a plan was there? It would be stretching things to even pretend that there had been a, sequential, series of [conflicting] plans. Which is wrong isn’t it?

Well maybe, but the plan isn’t changing that much. Basically I’m not going to archive this rubbish until block 2 of both courses is complete [which will be 2009-02-01]. This will, hopefully, give me time to catch up on some of the many undone things on my to-do list. Which might give me more time to do this. [You know that this is crap, don’t you?]

Course wise

Things aren’t too bad. I’m not, actually, behind on either course; not ahead, on the pace you might say.

As stated above I’ve been doing a lot of maths over the festive season, in between sleeping and drinking. I’ve even managed to get my second TMA nearly finished. Barring the MathCad stuff that is. That’ll have to be faced sometime this week, a prospect that doesn’t entirely appeal.

I’m actually quite pleased with the way things are going maths-wise. I think that I may have made a slight breakthrough.

My main worry was that, although I wasn’t having too much trouble working my way through the course books, when I came back to things they didn’t seem to have stuck. So I tried a couple of strategies.

  1. I did all the exercises in the books. And then I did them again.
  2. I tried to create my own exercises.

Which worked, sort of. But it still wasn’t doing the trick. I needed something more. Which is where my massive sleeping over the holidays came in. The thing about sleeping too much is that eventually you’ll find yourself lying in a pleasantly muted light, feeling warm and allowing your mind to roam. And when there are no pressing problems this is conducive to proper strategizing. So I did so.

The results? Well the first thing that I noticed was that I was lacking in, what I shall call, technique in some areas. For instance my trig. was less than perfect. The solution—play around with triangles. So when I was up and had a pencil in my hand, instead of a drink, that’s what I did. [There were other areas where I was weak, but I’ll leave them to one side for now.]

Now I’m not saying that I’m much better, but I feel much more confident, and I have to look up things like what cos(π - φ) is a whole lot less than I used too. Early days yet I suppose, but it has increased my confidence.

The second thing? Oh dear…

I’m opening MathCad!

2009-01-16

More books

The books for blocks three and four of the computer course arrived yesterday. More books to litter my bedroom floor as my wife archly observed.

Aside from the mess issue, the burning question is why are there two mailings? As the course units, for both courses, are available in PDF format on the web site, why aren’t they all mailed at once? If you get ahead the temptation is to contribute to planet-wrecking by printing them off, which I succumbed to—I printed units nine and ten of the computer course. [Nobody can work from an on-screen PDF]. And it’s bad enough having to be in for one delivery never mind two.

OK, rant over, time to review the aforesaid books…

Learning curve

Is definitely getting steeper for both courses. Some of the stuff looks really horrible [as in hard]. Of course there’s a difference between looking hard and this actually being the case. Having worked my way through the first couple of units of block three of the computer course I think that this may well be the case here.

∃ p in int[(p > 3) ∧ (p < 22) ∧ (MOD(p, 5) == 2]
on first blush looks like gibberish, and difficult gibberish at that, but if you don’t panic it isn’t that difficult to get your head around.

You have to be careful not to handicap yourself by assuming that things are more complicated than they really are. For instance, we are just starting the calculus block for the maths course—I’m willing to bet that this is scaring the living jobby out of a lot of people. I remember not liking calculus at school, I could do it to a certain extent, but I never really ‘got’ it. But after doing a wee bit of the unit I’m fairly confident that I will be able to understand it. In fact I’ll go out and a limb and say that there isn’t anything very hard there at all.

Well maybe it is hard, but if you tackle something with the attitude that it’s going to be difficult then it will be. It’s a self-fulfilling prophesy. Whereas if you start off without any pre-conceptions then, even if you do have trouble understanding, you aren’t going to put needless road-blocks in the way.

A better programmer?

I’ve been doing some major JavaScript work [for the first time in ages] and I’ve noticed something interesting about the way that I tackle it. With JavaScript you generally know what it is you want to do [in the case drag-n-drops] and you just have to work out a way to do it. Notice that I didn’t say the best way, or even a good way, just a way. The process in this case went [something like] the following:

  1. I need to trigger the drag and I don’t want to attach events to every element, so I’ll use delegation. I’ll attach an event to the body and see which element triggered it.
  2. I need to absolutely position the element—I’ll use a CSS class.
  3. To do the dragging I need to check where the cursor is and move the top left hand corner of the draggee there.
  4. When the mouseup event fires I need to stop the drag and remove any event handlers.
  5. Now I need to put the element back into document flow, so I’ll need to know the offsets of the other elements are. I’ll store this in an array when the drag starts.
  6. Oh, I need to account for scrolling…
  7. I need to indicate where the element is going to be re-inserted—I’ll use an <hr /> inserted into the document.
  8. And so on…

I don’t sit down and plan this before I start; I work on a wee bit at a time, I write a function, test that it works and move on. This works for me but there are obviously issues with my methodology. It isn’t guaranteed to produce the optimal solution, in fact it probably guarantees the worst solution.

But the interesting thing is what I do when I get everything working. I stand back from the code and think how I could improve it. I’m not talking about subtle tweaks [although I do these too]; I’m talking about major re-factoring. I call my initial code “the quick and dirty”, I always intend to re-write it later

For example [for the drag-n-drops] eventually I’ll create a drag class, so that I can exploit a closure and I’ll use prototypal functions as its methods. I also have to think about the way that I implement the ‘marker’, I won’t go into details, but it feels a bit processor intensive. There has to be a better way to do it.

So in the end I do the ‘right’ thing don’t I? No

The problem

Well there are manifold problems, for one thing I probably have to put in more work than I have to, but there is one big one—by the time I come to think about the architecture I’ve already developed a mind-set as to how it should be done. And I’ve got a working implementation of it! I may miss a much better way of doing things because I’m partially wedded to the way that I’ve already done it.

If I sat down before I started and developed a functional specification I’d think more about the task’s structure and how the code should reflect this. Only then would I concentrate on the implimentation.

And this is the solution.

Now, I knew of the importance of developing a specification before M263, but I’d never applied it to the actual writing of code. When I was designing, say, a database based contact form I’d figure out what elements I’d need and how they would interact, there would be much pencil jotting. But when it came to writing the actual code I’d just plunge straight in—do a wee bit, check that it works, do another wee bit.

This will also help with testing, something that I’ve been trying to be much more careful with. I spend some time [away from the computer] writing down a checklist possible test cases which I then test against. If I had a written specification I could ensure that my implimentation[s] were fufilling it.

Well full of good intentions I’m off to re-factor some code…

2009-01-27

Arrgh!

I’m at work—nothing very special about that and nothing very special about me writing this guff here. What is unusual is that I’m drinking a beer; I don’t drink at work as a rule. So why am I doing so at this moment? Well I’ve had a shock, I’ve been trying to use M$ Word to write out some mathematical formula.

Something that you may, and I did, think would be a doddle. Word has more whistles and bells than a gaggle of jesters. I’d thought that it would be so little of a problem that I even posted to the M263 forums about using the character map to do it [you can’t—well you can but it ain’t pretty]. Oh you can use insert → symbols, but these have a line-height of about 10 ems which messes up your document flow good time. [Coupled with automatic auto-list we’ve got your ultimate “what the shit”].

Well the first bottle has gone down and I’m feeling a wee bit better—I should count my blessings, at least the paper-clip shite didn’t pop-up offering to make things worse for me. But really what’s going on here? I’ve spent the last couple of hours wrestling with the help system, and several documents trying to do something that really shouldn’t be that hard. Doesn’t Word support Unicode?

MathCad—all is forgiven.

Well now the second, and the third beer have gone down so I’m going to post this now.

2009-01-29

Hmm

I was a wee bit on-edge when doing my last entry. In my defence it took far, far, longer to create the Word document, that I need to submit, than it did for me to work out the actual answers [something in the order of twice as much, and it’s still not finished]. Which caused rage mode to be engaged. So I’ll let myself off a bit.

But there is a question as to the wisdom of blogging that you’re drinking at work, while doing so—an error on par with that mis-sent slag-off email. The temptation to delete the entire thing is strong. However, I’m going to let it stand—who reads this tripe anyway?

Anyway, let’s try again with the more sensible part of the other night’s post.

M263, is it making me a better person?

I’ve spent the last couple of weeks thinking more about computers than maths. Partly because I’ve got a TMA due for the computer course, but mostly because I’ve been doing a lot of JavaScript recently. So I’ve been thinking about whether M263 has helped to make me a better scripter. [We say things without meaning to: I’m now a scripter not a programmer, and it’s M263 rather than the computer course].

I said below that I needed to plan more, so pencil in hand and reams of paper on floor I did just that. There were a couple of interesting results:

  1. I think that initial planning help me choose a better strategies [algorithms, methods, whatever…] than I would have without it.
  2. I know that it has helped me with the course.

I suppose that number one is a given, planning always helps. Or does it? I suspect that the kind of planning is more important than the actual act. But doing the code specification before the implementation certainly felt better. I’ll come back to this later methinks.

Why did doing it help me with the course? Well M263 is slightly artificial [which isn’t a criticism—it’s meant to be], so trying to relate what you have learnt there to a piece of ‘real world’ scripting helps broadens your understanding. In an attempt to convince you let me give you the following example.

The problem

I’ll try to avoid any JavaScript subtleties here.

FireFox [and other browsers for all I know] treats line-feeds as proper nodes. I’ve never plumbed the problem too deeply, I just know that node.nextSibling won’t always return what you think it will, i.e. an element node.

The solution

A function; one that “walks” the DOM until we get to a real [i.e. element] node. Element nodes have a nodeType of 1. So here’s my ‘walker’:

//DOM walker var walkDOM = function(node){ //get a real node while(node.nodeType != 1){ if(node.nextSibling){ node = node.nextSibling; } else{ return false; } } return node; };

So let’s try and write a specification for it shall we?


function walkDOM(node in nodeRef) return in nodeRef |_| Bool
pre: true
post: returns a node reference of a node element that is a sibling
or false if there are no more siblings in the parent node.

There are things to notice here:

  1. HTML doesn’t always do maths characters any better than Word, which is why there’s that weird collection of symbols for a disjoint-union.
  2. That nodeRef bit. That’s right, it’s being passed by reference and I’m not using clone(). So the function has side-effects.

Not much that we can do about 1, but what about 2? This is where it gets interesting—there isn’t a way to write this function without side-effects. If I use node.cloneNode() it does copy a node but it also takes it out of the document flow;
node.nextSibling is null which defeats the whole point of the function.

So I can’t do that, but it also means that I don’t have to return the nodeRef. True, but I still do, and I do an assignment when it gets back:

n = walkDOM(n);

Why? Because the way that code is written may be more important than what it does. I could do this in a slicker fashion [less lines], but someone else [me?] coming along later might not be able to see, at-a-glance, what was going on.

Erm, your point?

This function can’t be written in valid course code, but I had to justify to myself why not. And when I’d done that I needed to minimize the damage. It made me think about real-world examples and to go back to the documentation to see how I could deviate the least.

Which brings me to…

The maths course

I’ve done maths to a certain level in the past, but it was always divorced from practical usage. This is where I think that the maths course shines; right from the off you’re given examples of where this particular technique has a practical use.

For me this is what works: can I use it to solve a problem? For both courses the answer is an emphatic yes.

So?

I’ve [again] managed to convey what I’m trying to explain extraordinarily badly, and I haven’t done the CSS that’s going to make this page work; yup, drinking at work again.

Night, night.

2009-02-10

It’s a hard life

Apart from shovelling mounds of the white stuff, scattering salt like an anorexic sumo wrestler, and being cold I’ve been mostly doing maths recently. Well I’ve also been doing a lot of JavaScript, but I’ll talk about that elsewhere.

Apart from the snow clearing stuff, this seems to have been my pattern for these courses; two weeks of computing followed by two weeks of maths. What helps is that the TMAs are nicely staggered. It might be different if they were due with in days of each other, or even on the same day. In fact I can see that being a nightmare.

Healthy exercise

We’re doing calculus for maths at the moment and although I wasn’t looking forward to tackling this, I’ve found myself enjoying it immensely. It still doesn’t come completely naturally—I have to look up formulas too often for my liking. But it’s all coming back to me very nicely.

One problem is the lack of exercises. Well, there are plenty of exercises, but for calculus you really need to do thousands rather than the hundreds provided. And rolling your own isn’t really an option—you don’t have the answers.

I’m lucky in that I work in a school where there are a lot of old maths books lying around, and I borrowed [stole] a couple of my Dad’s old university text books. But once I’ve worked my way through these I can see myself haunting second-hand bookshops looking for ancient maths books. Is that sad?

Keeping my hand in

The other thing that I’m pleased about is that my writing stamina is getting better. When I first started doing my maths TMAs I noticed that after a while my wrist got sore and I had to take a break. In this age where everything is tippity-tapped into an electronic box most of us have lost the art of writing for long periods of time. “And this is relevant how?” Well you are going to be doing a three hour exam at the end of most courses—not the time for your arm to seize up.