Evan J Palmer's Blog

A blog about learning (code, improv, film and, anything else).

Month: February, 2013

Review – Lee’s Adventure


I watched Lee’s adventure yesterday and I’d say it’s one of the best movies I’ve seen in a long time.

It’s a beautiful and erratic Chinese film that bends time to really screw with your mind.

It’s about a young gentleman who suffers from a rare disease whose main symptom is the distorted perception of time. He meets a girl – shit gets crazy.

Parts of it are reminiscent of Fight Club, while other part are more like Primer.

Check it.



Storing a status as a string or an int?


Well here’s a thing.

Do you store a status in the database as an int or a string?

By this I mean, if you have a class:

public class BlogPost
  public DateTime DateCreated { get; set; }
  public string Content { get; set; }
  public [SOMETHING] PublishStatus { get; set; }

What should the [SOMETHING] be, and what should it’s corresponding type be in the database?

Usually I’d lean towards having an enum in code, and an integer in the database. The enum is easy to work with in code, and it’s easy to map from the DB (just cast it).

I think I’m starting to lean towards keeping the enum in the code, but using the human readable string in the database.

My reasoning is that it is much more descriptive. So we can look at the data and have no question about what the field means. With an integer we have to trawl through code to find the corresponding enum to find it’s meaning. So I think this change will speed up debugging and reporting.

I think it’s important to map this string back to an enum in your ORM/data access layer, so we can do trouble-free compares.

A way that this would work well with Dapper is to have a private memer that is a string like so:

  private string PublishStatus { get; set; }

This would be automatically mapped from the DB. We could then use a public method:

To get the enum value:

private PublishStatuses GetPublishStatus()
  return (PublishStatuses) Enum.Parse(typeof(PublishStatuses), PublishStatus, true);

What do you think?


Today I had to order by the PublishStatus. I went to do the ordering the database and realised that now that they’re strings, I can’t to a regular SQL “ORDER BY”.

Then I slapped myself in the face (metaphorically) that wouldn’t be testable anyway. So I wrote my test in C# and ordered it with LINQ like this:

  publishedItems = publishedItems.OrderBy(x =>; (int)x.GetPublishStatus()).ThenByDescending(x =>; x.DateCreated).ToList();

It worked nicely and is testable, which backs up my thoughts this is a good technique!

Improv Classes


Tonight I went to my first improvisation class with my buddy.

My aim is to get my communication skills up – kind of throw myself in the deep end and balance out my tech skills with some softer ones.

After the first class, I’m already happy. It was nice to get a bit of a release – so different from my regular development stuff, and I have to say, I was already starting to feel more comfortable by the end of the lesson.

I’m actually looking forward to the next one.