Month: October 2016

Why I like XML

So, I haven’t been programming long enough — and certainly not well enough — to be allowed an opinion on what other people should do. But, I do think I can share why I recommend using XML to other new programmers.

It’s fair to point out that I’m talking about programming in Python with the Element Tree library.

It behaves like you’d think.

I didn’t fall in love with programming until I discovered object-oriented programming. It’s just easier for me to abstract out the idea of the different parts of a program as ‘objects’ that interact. (I can write a bit on object-oriented programming, if you’d like, too!)

A lot of my programs are just collections of objects. I have a dictionary object that manages so many word objects, for example, in my ESL worksheet application. And, when I need to save all this as a file, it’s nice to have a format that makes sense.

The way that it makes sense to organize all this data, to me, in the physical world, would be a great big folder or binder with lots of other folders and binders in it. But also, with thousands of loose pages.

There would be a binder that is labeled “Dictionary” and that binder would probably have a name and, because I record dates unnecessarily, the date when it was created. Inside, each word would be a folder that contained information on the word, its German translation, space, maybe for other languages, as well as things like what part of speech it is and if there are other words that have the same text. (A real example from my teaching: I teach in one company where ‘forks’ normally mean the parts of your bicycle that hold the front wheel, but I also teach a lot of people who also think that a fork is something to eat with. Obviously, it’s going to make a difference in the worksheets.)

And these word entries should have a unique label of some kind (so the different kinds of ‘forks’ can be referenced later) and, of the other binder full of sentences contains a good example sentence for this word, I might want to store the unique label of that sentence.

That’s all the data I have in this binder, right? (In your typing trainer, the binder might be for a single user — with records on the letters they’re learning, another with a list of keys they often miss…) And what’s great about XML, is that it gives me a way to save data in this format, if I only think about it the right way.

Even more than just saving it in this way, the Element Tree library gives me objects (they’re called Elements and SubElements, when I write about using Element Tree I’ll write more about it.) that behave this way. That means I can assign an entire Dictionary to a single variable and pass it to a function or a method.

In fact, a lot of my programming is basically writing objects that take a single XML object and ‘bring it to life’ by adding methods to work with the data in it.

You can read it.

Here’s the other thing about XML: I can use it to store data and then, when I realize I’ve made a mistake (there’s a typo in a word, or students say a definition I wrote is unclear), I don’t need to write up a bunch of code to access that data and change it — though I should and eventually will — but instead I can open the file in any editor and edit the file.

I don’t think it’s possible for me to overstate how thankful I am that I can read and directly edit the information I have stored in XML. Even more than being convenient, it’s reassuring to me that I can fix my mistakes without too much effort.


This is the first in a small series I’m doing on XML for my nephew who is also a new coder. He recently wrote me that he’d rather just set up a text file for the Typing Challenge I set him. Of course, he can do what he wants, but I think it’s the prerogative of an uncle to send long, rambling dissertations on his opinions.

Advertisements

Working with Working Code

This is a tales of pros and cons. I set myself the goal of creating my worksheets this (academic) year using my worksheet generator. The results have been mostly positive — the students don’t know it, but I’m proud as hell of the worksheets I hand out, the students are benefitting from the way vocabulary is repeated, and even the errors are room for good, spontaneous discussion — but mixed.

Basically, I’m leaving PyCharm open all the time, because if I’m at my computer, it’s either to improve the code (i.e., do some coding) or to use the code for its intended purpose. Somehow, I feel like I’m a one man example of the idea of producing “banana software,” developing features as I need them, often under a deadline which, though it may be self-imposed, feels ominous. (Right now, I’m taking a break from coding a new type of exercise which is called for in next week’s lesson plans — sure, I could just cancel it [I have a great relationship with the customer], but that would mean admitting defeat.)

The pros:

Basically, what’s great about what I’m doing now is that I keep realizing that my planning was incomplete. It’s in the usage of the software that I realize  how much more it could do. Some changes are just inserted as TODO comments in the code like “It would be great if this worked with that” others I implement immediately, because I realize it makes no sense to code the rest of the features if these basic things are going to change.

Even more, it keeps me at coding. Knowing that this stuff has to be finished by next week keeps me at my keyboard when maybe I’d like to be in a hot bath. And that keeps everything fresh in my mind. Great.

The cons:

Obviously, the pressure is a double-edged sword, but I generally embrace it. However, it does mean that I feel this pressure to code forwards, rather than backwards.

I don’t know if coding has directions. What I basically mean is that I feel the need to add the features, rather than improve how past features work. An example is from the exercise I’m coding. It’s being coded as an object and I’m copying and pasting so much from other exercises that, even though there is a base class that they all inherit from, there should be a second base class for this category of objects.

And I could get that done in less than an hour, probably. But I don’t have that hour.

The thing is this: I know me. I’m proud of accomplishments that I can see. I don’t know that I’ll ever come back to this once everything is working, because cleaning up code doesn’t feel like an accomplishment the way that writing code does.

Maybe, I need to work on myself as much as on the code.

 

It doesn’t have to be on your phone

After completing the django girls workshop — I still want to do the part with authentication — I’ve been looking for a ‘minor’ project to code as a web app. (That’s in quotes, because I think they all grow.)

I’d thought about a beer calculator — for brewing, how much grain to how much water, that sort of thing — but there are plenty of good ones out there.

And then I realized, in my lifetime (not that long!) we’ve gone from assuming things will be websites (“Ha, you could call it ‘myidea.com’!“) to assuming they’ll be apps (“That’d be a great app!“) But that’s probably because we read more about apps.

I’d had the idea for the Fantasy Pilgrimage for a while. Of course I imagined it as an app — after all, I think like many other people — but there was nothing to say that it would have to be.

Here’s the idea (of course, read the page on Fantasy Pilgrimage). But, it seems like a rough draft of the site would be a success if it could do a few basic things:

  1. Use the Google authentication service
  2. Connect to Google Fit to get fitness data.
  3. Calculate total distance traveled since a given date, towards a total.
  4. Display that as a percentage.

Of course, with time, I’d like to use Google Maps and display the progress. But, hey, first thiings first.

What my App does

I had an inspiration last night. I realized — after working on it for the better part of two years, including several reboots — what it is that my app does. I’m talking about the worksheet generator, which seems closer to becoming something now than it ever has before.

First, I think I have to mention what it isn’t.

What the worksheet generator isn’t

It isn’t just another application or website that promises to relieve you of the burden of preparing for your classes. I pay for such websites, and I think they have their place, but I’m not going to be able to compete with them, even by doing the job marginally better.

The worksheet generator will not be just one more place that you can go because you didn’t prepare a lesson and you want to print something out for that class that is starting soon.

Working just as much – or more – for more results

I realized that, if I had to tell another ESL/EFL teacher what it was that my app did, it would be to say that it does a lot of the ‘stupid work,’ so that the energy I invest in prep goes farther. There are a couple of ways that this manifests itself.

  • Organization: Never my strong point, this is what the project originally was supposed to help me with. The idea is to have a virtual record of what you’ve done with each group, in terms of grammar and vocabulary. The strength of this organization will be in helping to review regularly. And that brings me to the second thing:
  • Permanence: Maybe this is just one aspect of organization, but it’s something I’ve known that I’m bad at. I’m great at creating a single, excellent, engaging lesson. I’m not so great at tying them together into a series that makes sense in a meaningful way. The extent of my understanding of ‘permanence’ has been to say that, if we’re working on the simple past, I can do a series of lessons about the past.

    What I’d like to do in the future is to have a more clear sense of repetition, by which vocabulary that came up once is reviewed again and again in the exercises of the following week. Even more, I want to say “hey, we practiced this structure three weeks ago, let’s do it again with the vocabulary from last week.” And that brings me to the last main point:

  • Modularity: I don’t know if it’s just me, or if every teacher is lazy, but I suspect it’s the latter. If you’ve ever had a teacher, you probably know what I’m talking about. I’m talking about teachers who create one set of PowerPoint slides and then teach them forever. Or,  in my case, who prepare an exercise for one class and then modify it only slightly for another (generally to realize that I overlooked an inside joke meant for the first class and completely without meaning for the second).

    The thing is this: Most of the worksheets I create in OpenOffice are great for the class they’re created for, and only the top half of page two is really great for the next class. So, I could just copy and paste but, inevitably, searching through everything I’ve made to get enough material feels like more work than creating a wholly new worksheet.

    When I talk about modularity, I’m talking about defining — in XML or in code — the basic structure of some exercises and stringing them together (simple past is comprised of these 10 or so modules, some are text explaining regular, irregular and the ‘be’ verbs in the past, others are exercises practicing them…) and then just saying to my app “hey, we’re starting this block on the simple past” and it adding one module to each worksheet until the block has run its course.

    It’s important to note here that this is going to be in addition to the other ‘modules’ in each lesson’s worksheet — whether they’re vocabulary review or a reading text to take home as homework. And, further, that a module is going to define how the exercise is created, but I’ll still be prompted to generate new content for it (“Enter a sentence in the simple past using word ‘ginormous’.”) (Fun fact: I’ve never taught that word in my lesson.)

Looking at what I’ve written, I’m beginning to think that maybe the unordered list might not have been the best way to get that done. Still, I think that summarizes what will eventually make the worksheet generator different from the “we do the work so you don’t have to” websites.