Some Coding Goals

Setting my own goals

It was not a super-productive summer for me, coding-wise. However, as I get away from ‘vacation-mode’ and back to ‘real life,’ in addition to improving as a teacher (more on that in another post), I want to improve as a coder.

Here’s the thing: There are a million ways to improve as a coder. And, I’m sticking to the ‘hobby coder’ label, so I don’t feel compelled to even try an know everything about coding, or even a specialization under the ‘coding’ header.

My task: is to be able to do the things I want to do, nothing more, but also nothing less. (To be honest, it will always be something less — I have an active imagination for what’s possible.) Now though, what I’d like to do is to make the things I make seem more like a ‘web application.’

What’s a web application?

The short answer is: it doesn’t matter. As a language teacher, I’m a big fan of the idea that words only mean what you and the person you’re speaking to understand. And, when I say web application, I mean it in contrast to a ‘web page.’

To me, a web page is static: Some guy (me) writes a bunch of stuff, takes a bunch of photos, makes a video, maybe, and puts it online. The web page is your chance to interact with what I’ve made, on my terms.

A web application, on the other hand, is magic. Sure, some guy (me) made it, but it’s a tool that I get to pick up and use how it best fits in my life. A web application is my chance to take something algorithmic I’ve made, and let you run with it.

Don’t you already do that?

To be fair, yes, I think that Dynamic EFL already qualifies as a web application. But, it doesn’t feel like it yet. It feels like a series of web pages that the user moves through, ending with a PDF, the most static document format of all time.

It’ll always end with a PDF, because the whole idea is that it’s supposed to be hidden. The learner isn’t supposed to know you used a ‘tool.’ The learner might hear the word ‘tool’ and think ‘shortcut.’ The whole idea is that the learner thinks “wow, the teacher invested time in me. I’m getting my money’s worth.”

So, maintaining the PDF format at the end, the way I see to make it feel more like an application is to make better use of transitions between pages and modals (the ‘foreground’ pages that open ‘over’ the rest of the page — logins are often done in modals).

The best web applications — gmail, Google calendar — don’t feel like pages at all. It feels like you enter an address into your browser, and then you interact with an application. That’s what I’d like to do.

A good argument for it

First, I rationalize it would help make what I do clear in comparison to what teachers are already paying for — static resources presented on web pages.

Second, it’s a sales point. Done smartly, the transitions and ‘web app experience’ simply feels more ‘modern.’ It helps to explain why I’m taking money.

A roadmap

I don’t have a roadmap in the traditional sense. That’s where this little goal-setting exercise breaks down. I’ve started experimenting and I’m finding it pretty hard. I have used JavaScript to dynamically change content on a web page, but I haven’t made the animation part of that work, and I haven’t been able to load a new django view into one <div> of a page.

So, I guess I have my work cut out for me.

The plan, now, is to leave Dynamic EFL how it is as I begin attracting beta testers. Instead, I have a new project idea that I want to start from scratch as a web application (using Google APIs, no less!) (more information on the actual project in a future post). Then, when that’s working, I’ll be able to apply lessons learned to Dynamic EFL.

Wish me luck.

Advertisements

It grows!

Just a simple idea…

So, I invited some of the people who tried dynamic-efl.com (my worksheet making site) a while ago to return to the site and see if things appeared more streamlined, clearer. And what was the response?

“Toby, I tried to login, but I’ve forgotten my password. Doesn’t your site have one of those password-reset functions?”

Of course it doesn’t. Grr.

No problem, it should be pretty straight-forward to code and it needs to get done at some point, I suppose.

It still isn’t done.

Save the email addresses

It turns out that the way I had been creating users, I managed to accidentally forget to save their email addresses. Oops. So, even if the “email me a link to create a new password” function existed, it wouldn’t help.

I’ve fixed that.

Then, once I was working with the email addresses, it seemed logical to add them to the mailchimp list I’d been thinking about starting.

I got that done.

Of course, to avoid adding bad email addresses to the mailchimp list and getting flagged, it seemed logical to first add the addresses after they’ve been verified. But that required me to code up an email-verification system. No biggie, but that meant learning how to send email through django.

I got that done. (Interestingly, I can send it through gmail, which I find convenient.)

Since that was done, it seemed as good a time as any to add an ‘account_locked‘ flag to the Teacher model, which would throw up a message on several of the relevant pages saying “your account is locked…”

I got that done.

accountlocked

Then, it seemed ridiculous to have a ‘your account is locked’ message if the account wasn’t, actually, functionally locked. Once I dug out where exactly the downloads happened, it should be pretty simple to have it first check if the account is locked or not.

I got that done.

There still isn’t a password reset

It’s next on my list of things to do, but this sort of experience is pretty standard for me in my own coding. I think everyone imagines that ‘real coders,’ have a plan and sit down and build something logical from start to finish.

(Though there is comic evidence to suggest that isn’t true. I got this via “Coding explained in 25 profound comics,” which is worth a visit on its own.)

coding

So, perhaps this is just par the course for the coding experience. Either way, it’s part of why my next project will be to write a drop-in user management module for future django projects.

I’m enjoying this and learning to appreciate a lot about website administration. But I would not be upset if I only had to learn all this once.

If you’ll excuse me now…

…I’m off to write a password reset function.

Updating the Interface

I have been busy, and frustrated, as I work on the worksheet generation app. And, unfortunately, I haven’t been adding new functionality or improving the existing functionality. At least, I haven’t been improving it from the point of view of how the worksheets are made. I’ve been working on how people make the worksheets.

This is what the app interface used to look like:

old-formattingIt really isn’t bad, it’s just very basic. I knew I’d change it at some point — I use this site more than anyone else, and I have an idea how I want it to look — but I wanted to focus on features.

Then, recently, I invited friends and colleagues to try the website out. And nobody seemed to understand what it did. I told them (in emails, in person) and they loved the idea, but the interface that seems obvious to me… well, it obviously isn’t.

I had an idea: I’ll make a sort of tour you take, before you can sign up, that will explain the functionality with screen-grabs. 

But, there are so many things on my plate, I know the chances of me making the same tour twice are not great. At least, not in the same year. So, logically, the interface should be changed.

CSS is hard!

The thing about CSS is this: you can  download templates (like I did for the landing page, from a great resource called Start Bootstrap), and I figured I could easily adapt the rest of my page to match it.

Wrong!

To be fair, I haven’t yet come across a CSS problem that, once I figured out how to articulate it correctly, didn’t have a clear answer somewhere. (Also, I love the resources provided by W3Schools, but hate their search functionality. Are they trying to make money there?) But, every step felt like an uphill battle.

Eventually, I got to a point where I was starting to be satisfied with the result.

Hosting static files on django is poorly explained!

I’m starting a list of things that were hard for me to learn about django, to eventually explain when I feel like I understand them. One thing would be the deployment to linode (remember that?) and another would be hosting static files.

After a lot of googling and basically blindly trying things, I’ve stumbled into a configuration that worked. But, for a while, it only worked on the linode site and not locally and I was too frustrated to change it. So, every change I made had to be pushed to the site to be tested, which was also frustrating.

Then, I got around to working out my development file hosting and was able to test changes more quickly (and without feeling like I’d have ‘broken’ the site just then when a friend would try to use it), but when I pushed my changes to the linode server, I realized that I’d broken hosting there!

Now, things seem to be working both locally and on the server, and I’m going to not play around with it. But, I have other projects cooking, and I’ll need to wrap my head around this.

So, what does it look like now?

Obviously, after all that drama, you’d expect something amazing, right? Well, it turns out that I can fix individual problems, but I don’t really have much of a vision of an overall design. So, while the layout is basically the same, the new formatting is something I’d rather spend my time looking at:

new-formatting

It has a title bar that remains fixed as you scroll, and functions are presented as buttons (because they seem to suggest action) and, rather than telling you “there is enough vocabulary to make a memory activity,” it simply doesn’t show you the option unless there is sufficient memory.

I can live with this for the rest of the academic year, I think. Now, I just have to clean up all the pages and make a tour, as well as finishing up my ‘minimum functionality…’

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.

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.

Thinking like a programmer

So, a while ago, I asked some programmers who were learning English from me what people least understood about programming. (Because, who cares what they could learn from me, I’m about what I can learn from them!)

The answer I got surprised me. They said that people just didn’t get how well you had to understand a subject to write a good program to support it. In their cases, they wrote software to automate some parts of a civil engineer’s job and felt burdened by what they’d learned about civil engineering. “I was never interested in it,” on of them said, “and now, whenever I pull onto the autobahn, I check if the on ramp is banked the way it should be. Because that’s the part of the code I wrote.”

Coding, for them, wound up being like teaching English for me: learning about all kind of interesting things that you wouldn’t have otherwise learned, but not always completely content with the list of things they were learning.

“And it changes the way you think.” Quickly followed that example. “You start seeing everything in algorithms, in steps. And making things efficient.”

“I can’t watch my wife work at home.” The other chimed in, “she does things wrong.” When I gave him a quizzical look, he said “she adds steps to things that she doesn’t need to add steps to, like cooking.”

The conversation that followed was wide-ranging, from three guys in a room talking about their wives (we didn’t say anything bad, honey, I swear!) to the actual topic at hand. My takeaway, though, was that they were so obsessed with brevity and efficiency in their work, that it started leaking out into their day-to-day life.

The idea is simple: they were writing code that had to be executed in ‘real time’ (the user shouldn’t feel like she ever had to wait) and so it had to be as few steps as possible. After all, a lot of what they did was write stuff that would be applied to a lot of different data points. So, if you can skip two or three steps — in a process that’s going to be repeated a thousand or more times each time the user alters her plans — you’re reducing the risk of the software seeming laggy.

So, naturally, opening the coffee and putting the open container next to the coffee maker seemed like an extra step to them: why wouldn’t you first get the filter ready and then skip the steps of putting down and picking up the coffee? If you were making a thousand pots of coffee per morning, you probably would.

I’ve spent quite a bit of time in my Python playground of late, and I’ve enjoyed most of it. In case you’re wondering, I haven’t reached the point in my programming life where my obsession with speed leaves me criticizing my wife. It’s just lead me to the point where I can barely stand to see myself work.


I don’t pretend to be able to point to any recording of the words in quotes above. And nothing said in the conversation I’m writing about would have been said in especially good English. I’m just going for the gist. I doubt that either of the programmers, were they to read this, would feel misrepresented.