Category Archives: Development

Free Software and Failed Ideals

Once upon a time, the idea that “only the code mattered” was sold as a way to be inclusive. No one would be shut out if their code was good.

But building software is more than code. It’s design. Planning. Discussion. It’s figuring out use cases, misuse cases, and failure modes. It’s interacting with people.

And if you allow some people to treat others like crap because only the code matters, you end up causing harm and driving people away.

Which obviously isn’t inclusive.

If you mistreat people or violate ethics to make your “technically perfect” software, those people have still been mistreated. Those ethics have still been violated. People have created marvels of engineering and fantastic art by abusing or exploiting others. People have done the same while abusing or exploiting people on the side. And people have created wonders while trying very hard not to abuse or exploit others.

The accomplishment doesn’t erase the exploitation or abuse. And if you can accomplish something incredible without mistreating others, it obviously doesn’t justify the mistreatment.

But the culture of “only the code matters” turned into a culture of tolerating assholes because they were good at their job. The ends justify the means. From trying to enhance freedom, to embracing Machiavelli.

It certainly didn’t help that 90s hacker culture had a significant BOFH element to it, with its built-in disdain for those with less technical knowledge. The Free part tended to prioritize programmers and sysadmins over “lusers.” It was Animal Farm with computer users. Sure, we tried to throw off the corporate overlords who were dictating how people could use their computers. But some computer users were more equal than others.

So a lot of people who could have become part of the Free Software community found a hostile environment and left in disgust. Or fear. And even if you don’t care about the harm done to them, consider their potential contributions. Free Software has always had a problem with coverage: Programmers work on problems that they find interesting or useful. The boring parts, the use cases that they personally don’t use, tend to fall by the wayside.

Yeah, your code is good…but the spec’s incomplete because you pushed away the people who would have pointed out a common use case, or just how easy it would be for a feature to be misused. You didn’t think they were worth listening to because they weren’t rockstar coders. But they also had information you didn’t.

Not that throwing off the corporate shackles has worked out all that well. Every platform now has its own walled garden. Microsoft is less dominant than it once was, but we have new mega-corps who’ve managed to leverage an internet built on Free/libre and open-source software into their own positions of dominance. And trying to maintain services for people who’ve come to expect free/gratis has brought us to the point where adware is the norm, and surveillance is everywhere…to better target those ads. And the majority of computing devices out there are locked down, preventing ordinary users from tinkering with them and developing that technical competence that might bring them into the fold…

If we’ll even let them join.

How to get Grails to use a reserved word with Microsoft SQL

If you’re building a Grails application using a Microsoft SQL database, and you want to have a property on an object that’s a reserved word in MSSQL, like RULE, you’ll probably end up with a SQL syntax error because Grails, Gorm and Hibernate don’t know what words are reserved in MSSQL.

You can just use another name. Does the property need to be called MyObject.rule? You might want to call it something more specific anyway. Problem avoided!

But if you want to keep the name, or if you can’t change it in the DB (say, because you’re connecting to a legacy database), you can get it to work!

Use a custom mapping. Grails lets you map a domain object’s properties to a column that doesn’t fit the usual camelCase → snake_case pattern, and you can use the same mechanism to add the delimiters that MSSQL needs to use the reserved word as a column name. Problem solved!

static mapping = {
    rule column: '[rule]'
}

Now Gorm/Hibernate will use the right delimiters on the back-end, and you can keep accessing myObject.rule, MyObject.findByRule() and so on.

Webdev Tip: ALWAYS Put the Record ID *in* the Edit Form

I started out this morning happy with my web host. They’d sent me an alert about disk usage that allowed me to catch an error that would have filled up all the available space on my VPS and taken down this site and several others, and I was able to fix it before that happened. That changed as I discovered what had actually set it up, as revealed by another, more pressing issue.

Background

A few months ago, my VPS did lock up, because I’d set up backups on a new site and forgot to add a cleanup script. Tech support brought the server back online, I cleared out the backups, and I copied the script over from this site.

But this site’s cleanup script stopped running, and it reached 90% usage. The script was there, but the cron job was somehow pointing to the other script. I figured I must have messed it up at the time, made sure it was correct now, and moved on.

Discovery

Later this afternoon, though, I discovered that a test blog I set up last week was pointing to the wrong site. That seemed really weird. I looked in the control panel and it was very neatly pointing to the other site’s folder. How does that happen?

Then I remembered: A few days ago, I’d reconfigured several sites to upgrade them to PHP 7.2. I’d opened them in multiple tabs to I could get them all at once. And I had this sinking feeling.

Sure enough: DreamHost’s control panel doesn’t put the form state in the page. As far as I can tell, the ID of the record you’re editing is stored in the session somewhere, which is fine if you only ever have one page open at a time, but if you open two pages, it gets confused.

That’s what probably happened a few days ago: I opened two forms, saved them both, and the settings for one site got written to the other. And it’s probably what happened a few months back with the cron jobs: I opened one to edit, the other for reference, and it overwrote the wrong one.

As near as I can tell it’s just the one site that got messed up, which is a relief. Even better that it’s the test site and not, say, this one. But I’m still waiting for the fixed config change to take effect.

Lesson

Always, always put the record ID for an edit form in the form. People will open multiple records in different tabs or windows, to compare them or just to speed up their workflow.

If you store it in session, or in a cookie, or anywhere else, you run a good chance of saving the data into the wrong record.

Groovy, null, and ‘null’

Groovy will let you call toString() on a null object. The result is the word ‘null’, which might be what you’re expecting if you know the object is null, but probably isn’t what you’re expecting if you don’t.

So if you’re, say, binding a SQL parameter and you forget to check for nulls like you would in Java, and you forget to use a null-safe operator like you should in Groovy, and you get a null value, what happens? Does groovy…

  1. Throw a NullPointerException like Java?
  2. Set the field to null?

Neither. It sets the field to the string ‘null’.

Make sure to use myVariable?.toString() instead of myVariable.toString() for cases like this!

Mobile: Design for Offline

I’ve written about the trouble with using mobile apps in dead zones before, so I’m happy to see that I’m not the only one thinking about the problem. Hoodie wants to design for offline first, and is starting a discussion project around the issue.

Offline reading is an obvious application. Most eBook readers handle that just fine, though it’s easy because you spend a lot of time in each book so it doesn’t need to predict what you’ll read next. It would be great if Feedly would sync new articles for offline reading. Heck, I’d like it if Chrome on Android would let me re-open recent pages when the connection dies.

Beyond reading, many actions can be handled offline too. Kindle will sync your notes and highlights. GMail will let you read, write, label, archive, delete, and even send messages without a network connection. All your actions are queued up for the next sync.

There’s no reason this approach can’t be taken with other communications apps for messages that don’t require an immediate response, even with services like Facebook and Twitter. Short notes of the “don’t forget to pick up milk” variety. Observations. Uploads to Dropbox. Photos going to Instagram or Flickr. Buffer would be perfect for this, since you’re not expecting the post to go out immediately in the first place. It shouldn’t give you an “Unable to buffer” error, it should just save it for later.

I’d like to be able to do work in a place where there’s no connection, have that work persist, and fire things off as I finish them instead of having to come back to all of them the next time I’m within range of a cell tower or a coffee shop with wifi. I’d also like to be able to post in the moment, hit “Send,” and move on with my life, instead of having to hang onto that extra context in my mind as I walk around.