Categories
Development General

Data Access Layers

At my previous company we created a “data access layer” above all data access layers.  One guy mainly built and maintained our templates for generating code.  Another guy build complicated views for retrieving and updating data which applied business logic, etc.  The database became a repository for metadata about the system.  From then on, the data access layer took over and produced marvels. 

It was quite an amazing system, but like any amazing system it had its down-sides.  You really needed to be an expert to work with it, logic was many layers deep and it needed to load a lot of metadata before the system would start to work.  Basically there was a lot of overhead to get stuff done.

When I started at my current job I’d realised the benefits of automating data access, but foolishly tried to build my own data access layer.  For code to stand between the developer and a database, there’s a lot it must do before it starts to become an integral part of the system.  Unfortunately writing one from scratch, and writing it well is just too much trouble for most people (myself included).  The requirements are many, but most notably it needs to do two things:

  1. It needs to make the developers life easier
  2. It needs to impose standards

Unfortunately those often end up at odds, and even worse often rule one is lost completely.  Slightly more forgivable, rule two often is just really hard to maintain because each organisation has different standards so having one system that works everywhere is most likely unachievable.

So what’s a developer to do? Recently we decided to revisit our chosen tool for generating our data access layer.  We did some research, gathered the names of the most “popular” ORM tools and set about testing each one.  We have a fairly large legacy of code that we need to work with, so there’s a lot of customisation we need to make it work well and have the code look reasonably neat/legible.

We looked at Subsonic, NHibernate, Entity Framework, Linq to SQL, LLBLGen Pro, NetTiers, PLinqo and a few others.  It boiled down to cost vs customisability vs time and effort to setup.  Cost wise we were down to Subsonic, NHibernate, Entity Framework, Linq to SQL, Plinqo and NetTiers.  We dropped NetTiers because it hasn’t been updated in about a year, and dropped Plinqo because it was basically just a wrapper around Linq to SQL (plus we’d need to buy more licenses of CodeSmith).  So we were down to Subsonic, NHibernate, EF, and Linq to SQL. 

The first framework we tried was Subsonic, took 5 minutes to setup, a quick tutorial video and we were off (I read some documentation too).  Within 30 minutes I’d generated a data access layer, and within an hour I was customising the templates to do little things I wanted them to do.  It was simple, quick and efficient.

NHibernate was an eye opener.  Many config files, odd documentation, no easy “do x, y and z and you’ll have a DAL”.  I resorted to using a copy of CodeSmith with some NHibernate templates to generate the classes and config files for me and even then it was just too complicated.  I know it can do miracles, but we just need something simple and this much config is just too much trouble.

EF was easier than NHibernate, but still had its downfalls.  It offers the world, which means it has extra complications, models, etc.  There wasn’t an easy way to simply add a table to the database and have it generate the code for us in the custom ways we want it to.  The only real benefit it gave us was complicated ORM functionality that we didn’t need.

Linq to SQL is great, but again not much customisation, and really Subsonic and other frameworks provide better features.

So in the end it our decision was clear … Subsonic was the easiest.  Even before we’d made the final decision we had some of our developers asking “can we use Subsonic in project X?” 

The only down side so far to Subsonic is that submitting changes to their code/templates requires you to use Git, which so far is proving to be a real pain in the ass. I guess you can’t have everything you want in life, but at least I have a nice ORM now.

Categories
General

TopTV?

Being a guy and a geek, I tend to be rather gadget prone which can be quite frustrating when working on a limited budget. So when the 5 new pay tv licensees were announced about 3 years ago I rejoiced in the promises of lower cost pay tv and waited, and waited, and waited.

From the start ODM were one of the better sounding choices and they continued to be the leader of the pack until they finally were the first to launch their service publicly at the start of this month.

In the first day it was clear that they had hit a great price point with their offering. In the first few hours of that day they were sold out of their entire month’s stock of 50 000 decoders. At this point in the story opinions differ greatly… Either they are the most useless company in the world, or they have done a great job of dealing with a very sudden and very unexpected influx of customers. I am in the second camp and hopefully this post will explain why.

In only a few days they almost doubled their call centre staff. A few days later it grew again, and a week later it doubled yet again. In just over a week they also increased the number of installers significantly and they brought in extra stock in a few days to help relieve demand.

Systems intended to work with 10 000 subscribers suddenly had to work with 50 000 and I can’t think of many companies who would have handled this better.

All that aside, I prepared myself by looking on forums for information and expecting bad service due to an overwhelmed call centre and overly busy installers.

Last Sunday I decided to get TopTV and it was surprisingly easy. I called 4 stores, found one with stock near me, bought the decoder, came home and called the call centre. A short 15 minutes later and I was signed up and had details for three installers near me.

On Monday I called an installer and 4 hours later I had the dish and decoder installed by a friendly and efficient guy. Another 15 minute call and the decoder activation had begun.

The experience so far has sounded ideal, but it has not been without its problems. Activation of the decoder failed initially and it took a day to sort out. I didn’t get the promised sms to rate the installer’s work and I had to call in to find out how much I owed them. Three failures, but none of them really important.

When it comes to the decoder and service, I have had very few problems. The Electronic Program Guide (EPG) has been improving but has a long way to go before I would call it fully functional. My main gripes are that about 5 channels have no epg information at all, one is 2 hours out if sync and there are no episode numbers on the shows or years of production on the movies.

For now, however the detail has been enough to find whatever I would like to watch quite easily and considering that there are virtually no adverts on any of the channels at the moment I am quite happy with the compromise we currently have.

On the whole I have found it to be good value for money, with lots of potential to become amazing.

Categories
Geek food General

Children of Chaos

I have had this book on my bookshelf since 1997(or maybe 1998), but it has sat there unread for a number of reasons over the years but finally it seems my brain has been prepared enough to take it in.

If you didn’t get the blog post title, the book is Children of Chaos by Douglas Rushkoff.

I keep thinking that he is talking about YouTube or Twitter, things from post 2005, but then he starts talking about the new fangled browser Netscape, recently evolved out of Mosaic, and it hits home the fact that he is talking about our online world today as a “prophecy” of where he sees us heading based on the cultural shifts around him in the mid 90’s – 15 years ago!

There are bits of what he talks about that are only now starting to become reality in south Africa in the past few weeks thanks to the recent uncapped broadband offers at reasonable prices.  Video content generated by individuals not corporations (like YouTube or more specifically examples like our local ZA Tech Show Live Stream).

I am filled with great hope for a far more connected community, and greater freedoms and expressions of a non-traditional media.  He pre-empts some of the thoughts in the Cluetrain Manifesto (1999/2000), the blogging “revolution”, and the demise of traditional media (which has only really hitting the “front page news” in the past few years.

A lot of the concepts expressed in the book can come across as socialist, anarchic and anti-establishment dreams for the future but if you look beyond those labels you will find an expression of the struggle for meaning, relevance and the value of an individual within an increasingly global and politically correct society.

There might be a lot that is disagreeable in the book (depending on your personal beliefs) but the fact that his vision of where we would be heading from 1996 forward has such a lot of similarity with what has happened in the past 15 years shows that, whatever disagreements you might have with his philosophies, he has a good understanding of our culture and the forces that drove us forwards in the past 15 years.

Give it a read, you might be pleasantly surprised.

Categories
Development General

Java Dates from a n00b point of view

After spotting that seemingly 90% of the methods on the Date class were deprecated, I started getting worried.  Then when new Date().getYear() started giving me odd numbers like 109 instead of 2009.  I started thinking “Wow! Those Sun developers must have been on some strong drugs when they designed this language!”

So a bit more googling and some “WTF?!?!!?”’s later I found out that the Date class returns the time since January 1, 1970.  So of course .getYear() returns the number of years since then.  Well, not exactly.  Because there are only 39 years since 1 Jan 1970 and today.  So how the heck did getYear() return 109?  I didn’t bother to go any further than that – clearly the Sun developers were on drugs that should never have been invented, and I didn’t want to even think about starting to try and understand what was going on in their twisted little minds at that point in time.

BUT, I found out that they have a GregorianCalendar class which can help you out in most situations, even if it’s a little obtuse in how you use it.

The following code:

Calendar cal = new GregorianCalendar(mYear, mMonth, mDay, mHour, mMinute, mSecond);

Gives you a calendar object based on the input you gave it.  Now of course I get a Date object from a database so I want to do new GregorianCalendar(mDate).  But again, that would be asking too much, so instead of that simple instantiation I have to do:

Calendar cal = GregorianCalendar.getInstance();
cal.setTime(creationDate);

Why, on earth did they call it setTime?  I mean, I’m setting a date and time.  I’m not just working with Time here folks! Surely the method should be named something a little better like .setDateTime() or .setDate()?

But wait… it gets better.  You know the Date class had a getYear() method, right? Remember? It’s the one that requires large amounts of hallucinogens to understand or use!  Well, naturally you’d expect that the Calendar class would have a getYear() that makes sense.

That’s where you’d be wrong!  Since they started with the obscure requirement of doing .GetInstance() followed by .setTime(mDate), they clearly hadn’t quite yet gotten off their high when they made the get() method.  Here’s how you use it:

Calendar cal = GregorianCalendar.getInstance();
cal.setTime(creationDate);
mYear = cal.get(GregorianCalendar.YEAR);
mMonth = cal.get(GregorianCalendar.MONTH);
mDay = cal.get(GregorianCalendar.DAY_OF_MONTH);

Yup, that’s right… why make it as simple as cal.getYear() when you can make it cal.get(GregorianCalendar.YEAR)?  Perhaps someone over at Sun had some stock in a company that provides treatment for RSI’s, so that by making us type out loads more letters they hoped to make more of us suffer not only the pain of using their language, but also of repetitive stress injuries.

BIG DISCLAIMER:

From my brief work with Java previously, I know that the designers were NOT on any drugs and in fact they probably had very good reason for designing the classes the way that they did. It’s just not immediately obvious to the new user, and that’s mainly what I’m ranting about here.  So, to all the Java fanboys out there who are preparing to unleash their full fury on me for my sacrilegious comments about their language – please take a moment and laugh before you post. 🙂

Categories
Development General

Android, Eclipse and Java – First Experiences

After bitching about the lack of good tutorials last time, I found that I’d actually been looking at Android 1.1 tutorials and trying to run them on Android 1.5.

Now that 1.5 is out (well, it was released quite a while ago, but I’ve only recently started using it in earnest) I’ve re-read the tutorials and some of the introductory info on the Android Developer’s Guide. In my exploring I’ve hit MANY “Force Close” dialogs.  Unfortunately they never seem to say anything about WHY the app is being forced to close.ForceClose

The first few times I’ve just popped Eclipse into debug mode in an attempt to figure out what’s wrong.  Unfortunately it doesn’t seem to help much.The exceptions that end up being thrown seem really vague and not entirely related to the issue at hand.  So without any further blabbing, here are my top three reasons for getting a “Force Close” in my Android development:

1. Putting the call to setContentView at the end of the onCreate method instead of the start.

Initially I thought I’d be clever and first setup all my event handlers, and data binding and stuff.  But after some really confusing exceptions I realised that unless I call setContentView at the top of my onCreate, I won’t have access to any of the “objects” on my form.

2. Having an abstact class instead of a concrete class for my Activity

I’m not entirely sure how Eclipse and I came to this point, but somehow when adding this class I must have ticked a box that I hadn’t ticked before and suddenly the class was abstract.  No idea how or why this happened, and I certainly didn’t notice it at the time.

Of course I’d expect the exception to say something about “You cannot create an instance of an abstract class.” or something  meaningful like that.  But no, it seemed that this was not to be.

3. Not adding the Activity to the AndroidManifest.xml

This happened at the same time as the issue in point two so I’m not too sure if the two issues together just made the cause of the problem really hard to find.   Maybe I’m just too used to Visual Studio protecting me from myself, but this seemed a little silly.  I created a class that extends Activity.  Now I still need to go and add that info to the AndroidManifest.xml file?  I

People might think that I’ve been overly coddled by VS.Net, and that this is simply how normal development works.  If I used a Wizard to credit an Invoice, I’d expect to have a credit note created at the end, ready to send on to the client.  I wouldn’t expect to have to then go and specify the Client, and add the information for the line items, and then add up the totals manually and then finally to add on the VAT before I could send it.

There are a few nice wizards to get things started, but they often seem to only go half way. If I use a wizard, I expect the wizard to do the whole job.  So when I add an Activity to an Android app, I’d expect it to create the class AND enter the information into the AndroidManifest.xml file for me. Actually, in this case there is really no Wizard in the SDK toolkit to add the Activity – and that’s another gripe – there are wizards to create an Android XML file which is relatively easy to do.  But something like creating a new Activity requires a bunch of manual steps.  So where’s the consistency?

Anyway – enough whining.  Soon I’ll face the anger of a mob of Java developers. 😉

Categories
Development General

Exporting BlogML from Subtext 2.1 and importing BlogML into WordPress 2.7

I currently run by blog using Subtext and I’ve been wanting to test out some features in WordPress for a while.  So naturally I don’t want to lose all of my blog posts and I’m not keen to write a whole bunch of code to read from the one database and write to the other.

Fortunately Subtext has the ability to export to BlogML and WordPress apparently has the ability to import from anything (if you believe the rumors)  Unfortunately both the export and the import don’t really work.

Firstly, Subtext’s export doesn’t work. BUT since I had started my day thinking about moving from Subtext to BlogEngine.Net, I’d found a forum post where a friendly person showed how to make SubText export to BlogML successfully (Its the post by Harold on 2 Dec 2008).  He links to the binary of SubText.BlogML.dll – you just replace the one on your site (make sure you have a backup of your version, just in case there’s some issues with newer versions of Subtext)

Now for the import part – Thankfully Aaron Lerch had handled this back in WordPress 2.3 in his post about moving to WordPress from Blogger.   The important thing for me was his BlogML importer.

There are a few things that seem to have changed.  Aaron’s post uses “XPath.class.php” which you can get from Sourceforge.  It suggests that you put the file in the /wp-admin/import folder, but that just seems to cause issues.  So I’m going to lay out the steps that I took over here:

  1. Download “XPath.class.php
  2. Put the file in your /wp-admin/ folder
  3. Edit /wp-admin/admin.php and add a line at line 27 so that the file looks like:
    require_once(ABSPATH . ‘wp-admin/includes/admin.php’);
    require_once(‘XPath.class.php’);
  4. I’ve modified Aaron’s blogml importer and you can get blogml.php.
  5. Upload it to your /wp-admin/import folder

The original blogml had a few issues:

  1. It couldn’t handle   or > or even < in any of the blog posts
  2. Categories were not imported correctly at all
  3. It didn’t, and still doesn’t, handle draft posts at all.
  4. It didn’t work with WordPress 2.7

I managed to fix the problems with the escaped html, the categories and the WordPress 2.7 issues, but didn’t quite get to fixing the issue with the draft posts.  Let me know if you manage to fix that part – I only had one draft post so it didn’t really matter.  Hopefully this will help someone else though.

Categories
General Humour

Stand up for Sundays – SA Comedy

My company have a value where they take us employees out to social events once every month or so.  Last night we went to watch Stand up for Sundays by The Comedy Shop.  (I actually found them via “The South African Comedy Blog“.)

I’m not one who usually goes to comedy shows, but I’ve wanted to for a long time. So I was quite excited to go and see the show.  About 15 of us went, all from different cultures/backgrounds/races/etc and we all had an absolute blast!

The guys doing the show are Mel Miller, Al Prodgers, Kedibone Mulaudzi, Etienne Shardlow, and Alistair Plint.  (For those from SA Developer, Alistair is Ruari’s cousin)

The show was amazing.  I haven’t laughed that hard for ages.  Some of the members of our group looked like they were about to soil themselves they were laughing so much.  The show started with Alistair as the MC, giving us an intro to the evening, and cracking a few good jokes, then came Kedibone.  I’ve never heard of him before but he was FUNNY!  Had all us whitey’s in stitches laughing at ourselves as he showed some great “real life” situations for the silliness that they are.  Then came Al Prodgers, again super funny even if my inner prude was a little embarrassed at times.  (We bought a DVD of Kedibone and Al after the show, that’s how good they were)

Then on to the second half of the show after some drinks outside.  First up was Etienne Shardlow – “The School Boy”.  He didn’t seem to get as many laughs as the rest of the guys, but that might just have been our crowd.  Basically he (a fully grown man) came on dressed as a school boy and with all the nervous mannerisms that go with it.  I really enjoyed the “view of a child” that he showed.  And finally we got to see Mel Miller.  He had us “rolling in the aisles” (please excuse the clichés).  His audience interaction was awesome, taking cues from what audience members said and combining that with his train of thought to make something unique to our audience.  He’s probably got the most expressive face of whole group.

I wish I could give you a link directly to the Computicket page where you can buy their tickets, but I’ve yet to find a way to do that.  So the best I can suggest is to go there and search for “Stand Up”.  (Don’t search for “comedy” because that won’t get you to their show… not sure why, but hey, technology sometimes just doesn’t work)

If I had the money I’d tell you that I’d pay you for your ticket if you didn’t enjoy the show, but I don’t so you’ll just have to spend your own R80 or R90 (depending on where you get the ticket) to go see them.  I’ve subscribed to the Comedy Shop’s blog so that I can find out when next they’re doing another show so I can go see it.

Categories
General

More Ubuntu – Virtual PC’s

I’ve been playing with Ubuntu for a while. Besides a few oddities on my laptop, it has worked almost perfectly.  It works quite well, since I’m not an uber gamer, there’s not much that I can’t do via a Virtual PC.  I originally thought I’d use VMWare.  I’ve always heard about them and their products and so they were my first call.

The only problem is that finding support for their product was kinda tough.  I had a problem where my USB devices would just not get detected by the virtual pc and if they did they would not work correctly.  I found a number of articles talking about how to fix the problems but none of the solutions worked.

Eventually I stumbled upon VirtualBox which just seems to work so well.  I had some brief difficulties with USB, but VERY quickly found solutions on their forums.  I’ve had to do lots of forum searching since starting out with Ubuntu, and its getting a little tiering.  But its damned fast, and I kinda like the fact that I sometimes have to get involved just under the surface of the Operating System to get it working.

With Windows its semi-easy to do everything, but there are downsides… A fresh Windows XP SP 2 installation takes a LOT of updates and its pretty slow at getting them… My Ubuntu install did a few updates, and they were damned fast.  It seems that ubuntu has update servers in various countries around the world, and one of them just so happens to be South Africa.  Not sure why Microsoft doesn’t do that, but ubuntu’s updates certainly do download WAAAAY faster than my microsoft updates, and there’s a damn side less reboots involved.

Categories
General

Notepad2 Updated

I found out about this cool tool a few years ago and have used it since then.  Its free, it works, and it does syntax highlighting for all of the common file types that a developer might want to ever edit.

I just read today that its been upgraded to v2.0.15.  NotePad2 is great!

The only hassle I’ve ever had is with replacing Windows’ notepad with NotePad2.  XP SP2 likes to keep its version of notepad in place, and replaces anything that isn’t MS’s version.  One workaround I’ve seen is to rename Notepad2.exe to Notepad.exe, then to have a batch file copy it into the following folders, one after the other with no prompts and no pausing:
    C:WindowsSystem32dllcache
    C:WindowsSystem32
    C:Windows
I’ve had mixed results from doing this, so YMMV, but here’s the contents of my batch file (which worked on my PC):
    copy /Y notepad.exe c:WindowsSystem32dllcachenotepad.exe
    copy /Y notepad.exe c:WindowsSystem32notepad.exe
    copy /Y notepad.exe c:Windowsnotepad.exe

Categories
General

Ubuntu Links

Before I start on the links… People complain about windows XP having to download lots of updates after it is first installed.  Well I’ve found out, at work, that Mac’s have a lot of upgrades too and so does Ubuntu.  Tonight I got prompted to download about 238mb of updates!

So far I’ve found that SyncCE along with MultiSync should work ok with my HTC TyTN. And it seems that “gnomad” should allow me to connect to my Creative Zen MP3 player. Both require some effort on my part though – like building from source code – so I’m going to leave them till a little later.  Ubuntu’s “Desktop Guide” actually seems quite good.  It has pointed me to a few nice resources, although it appears that my Cannon 4400F scanner and my HP 1600 Color LaserJet won’t work through Linux.  So the two things I thought would be impossible (synchronisation with my TyTN and my Zen) are quite do-able and the two things I thought would be easy (connecting to my scanner and printer) are going to be imposible.

Oh, well. It just goes to show that you can’t predict much in life.  Like how my cat has just gone missing (she’s not quite used to our new home yet so she gets lost in the complex).  So I’m going to go off and look for my cat while Ubuntu downloads its 238mb of updates. 😉

[Update: Ok, so it looks like my printer might work after all.  I found two links with info – one specifically at LinuxPrinting that seems to be promising.]