A few code style conventions I’ve adopted

April 16th, 2015 No comments

I write a lot of code, and here are a few little stylistic things I try to always do now.

1) Mandatory comment when passing boolean flags or weird random args: I learned this one when interning at Facebook. What’s the third arg here??

processDatabase(server, "Users", true);

No more mystery flags! You must comment it so I know what the heck I’m passing and what it means.

processDatabase(server, "Users", /*overwrite*/ true);

2) Mandatory comment on an empty block: Sometimes I have an empty block or empty loop or whatever. But here’s one in my code; did I mean to do that? Is it a bug? Just comment it and be sure. Got this one from Eric Roberts.

// should this ctor be empty?? (bad)
public FluxCapacitor() {

// this one is better
public FluxCapacitor() {
    // empty

3) Author/version comments on files: It seems like a simple/obvious thing, but just tagging my files with my name and when I last modified them has helped me a lot with “is this the newest copy of this file?” issues. I also put in what I changed between each version.

 * FluxCapacitor.java
 * ........ (description)
 * @author Marty Stepp
 * @version 2015/04/15
 *  - fixed bug with null pointer in query function
 *  - alphabetized function names
 * 2015/01/29
 *  - added getRandomBlerg() method
 * ...

4) Two-letter for-loop counter variable names: It’s a nightmare to search for “int i” in your code. How about two letters?

for (int ii = 0; ii < 10; ii++) {
     for (int jj = 0; jj < ii; jj++) {

What are some little style rules that you love to follow in your own code?

Categories: Uncategorized Tags:

Movie Review: Hobbit Battle of Five Armies

December 27th, 2014 No comments

Saw Hobbit: Battle of Five Armies last night. One word review: Meh. Longer review: Unnecessary. (SPOILERS BELOW)

It’s a nicely made movie, with good visuals, good f/x, good acting, good music, good action, etc. It’s not sloppily done. But I just didn’t connect with it. It felt so unnecessary. I didn’t like the other two, either; it all just felt bloated and padded out to ridiculous levels. This movie and the last one, Desolation of Smaug, really felt like one movie to me. This third installment, almost the entire movie is just one big battle sequence, and after a while I just stop caring about the various characters and armies that have been poorly introduced and haven’t done anything to make me feel invested in them.

That’s the biggest sin of these movies: the weak character development. In the LotR trilogy, almost every single character was interesting and made me want to see more of their story. Think of Gimli and Legolas, think of Boromir and Faramir, think of Arwen and Eowyn, Galadriel and the elf lord Elrond. Think of Gandalf. Saruman. Every character is fucking badass. In this one, they fail to make me care about these dwarves traveling with Bilbo, to the point that I can honestly not tell you who more than 3-4 of them are, despite having their names memorized from reading the book.

I like Radagast the wizard, but why does he have bird poop all over his head and act like a dolt?? Why does the awesome bear-man Beorn barely get any screen time? Why does the awesomer Smaug barely get a line in this movie? And/or, why didn’t they just resolve the Smaug story in the last film rather than ending that one in the middle of the action? I actually didn’t mind that they added Azog the pale white orc, a made-up character for this movie so it would have a main bad guy … but then a lot of the other orcs in this one have the same pale white skin, so it’s hard to tell which one is Azog! They give a lot of screen time to this weaselly guy Alfrid and give him a unibrow and bad British teeth and have him act like a conniving jerk and give him lots of goofy comedy lines. Is he the Jar-Jar of the Hobbit?

They add Kate from Lost as a she-elf, but then her entire purpose is to be a prize for … Kili? One of the dwarves. Who just dies anyway, so nothing comes of it. And hey, why is Kate-from-Lost-elf allowed to love a dwarf like it’s no big deal, when Arwen in LotR needed to give up her elf immortality to love Aragorn? Why is Legolas in these movies, and why can he jump on/off of falling rocks as if it were a video game?

The primary villain, Smaug, gets dispatched in the first 5-10 minutes of the movie by “Bard”, some random character who just showed up near the end of the second movie and to whom the audience has almost no connection. He comes from some town full of uninteresting people, with whom the audience also has almost no connection. Yes, I know that’s how it was in The Hobbit book, but if they’re going to change things, why not strengthen this character and involve him more in the overall story?

There are also things in here that make the LotR trilogy not make sense. Like, if Gandalf is going to see and face Sauron so much in this movie, including being held captive by him and everything, then why is he completely shocked and surprised when he discovers that Sauron and the ring have returned in LotR Fellowship of the Ring? Why do the Nazgul not look or act the way they do in LotR at all?

I really wanted to love these movies because the LotR trilogy is among the best film series of all time. This Hobbit trilogy just felt like going through the motions. All the action and look/feel of LotR but none of the heart or character. Hours of CGI armies fighting and dwarves floating in barrels and white orcs, full of sound and fury, signifying nothing.

This book should not have been made into three movies. I could actually picture them making two good ones out of it, or even one, though a single film might be overly cramped. It should have been two. There were two really neat movies here, or three mediocre ones. The studio chose the latter. The Hobbit: Battle of More Monies. I can’t wait until Peter Jackson releases the Special Editions where Gandalf doesn’t shoot first.

Categories: Uncategorized Tags:

Switching to Linux Mint

August 11th, 2014 No comments

After several years now using Fedora Linux 16, which is now dreadfully out-of-date, I am switching my laptop to run Linux Mint instead. I looked at several distributions, including the newest Fedora, Ubuntu, Elementary, and some others. The sense I got is that Mint is a cleaner, leaner, more usable branch of Ubuntu without the crappy user interface decisions that have infected Ubuntu lately.

As of this writing, the current version of Mint is Linux Mint 17. I got the 64-bit version as an ISO image, then used a program called ImgBurn to burn this to a DVD. But then I remembered that my laptop doesn’t have an optical (DVD/CD) drive. :-) Another complication is that switching distros requires a full drive format, which erases EVERY file on the system. So I had to wait until the end of summer teaching to get all of my important documents backed up first.

To get around the no-DVD-drive issue, I got a USB stick and a program named unetbootin that can make the USB into a bootable drive image. Then I booted up my laptop, hit F12 to open the boot device selector, chose the USB option, and bam, I was booting into Linux Mint.

This post isn’t intended to include my detailed impressions of Mint; I’ll probably write about that later on. So far it looks nice and feels snappy, where Fedora always felt a little bit visually laggy in its UI for some reason. I like the look of Mint and the generally more Ubuntuey approach of its setup; I never was a RedHat/Fedora/RPM guy.

Categories: Uncategorized Tags: