Archive for August, 2008

Learning things the hard way

August 28th, 2008 by sjan

These are some things I learned the hard way over the past few weeks. Ignore at your peril!

  • When your setup requires a different database layout (meaning differently named and/or organized databases and/or servers) for development than for live deployment, you would do well to try to mimick the live layout in your development environment before beginning. (This one hurt, bad.) In fact, when you find a need for your application to test for current environment (development vs production), you may want to be extra certain that you really need to set up your development structure that differently.
  • When your test & deployment environment calls for a server external to the existing systems and database servers, make sure that you:
    1. Have a clear understanding of what packages/versions that server will need.
    2. Have a clear understanding of how long it will take to get the hardware in place.
    3. Have a working copy in a VM on the same OS that the server will be deployed on before you say ok to anything.
    4. Ask, beg, plead, whatever, for a copy of that server (even on desktop hardware) to be set up for the testing. If you cannot test against real machines in a real environment for any kind of multi-server deployment, all bets are off. (Um, yeah, again, ouch.)
  • While the occasional 12+ hour day for developers is inevitable, too many of them in a row will result in more mistakes and coding errors of the most simplistic sort.
  • When you discover that you need to add functionality to an integral part of the software (like, say, the primary db connection class) do everything within your power to ensure that it still “works the same” – that is, add any modifications in such a way that they do not break existing code. This is not always easy to tell, but usually a simple trip around the application will tell you quickly if you have broken something as basic as this. (No, I didn’t break it, at least not anywhere other than locally. I actually took this step, many times and saved myself great embarrassment.)
  • Finally, when switching between languages (PHP, Java, Bash, Javascript, etc etc) you may find yourself looking at code that should work, but doesn’t. Chaining calls in PHP seems to be iffy at best. For example:
    • This does not work, although it seems it should. The $db is an instance of a legacy database connection class used for the project, do_query returns an array of results, and do_query with a second argument sets the value of the field named as the key for each row:list($account) = array_keys($db->do_query(“SELECT account_id FROM reports WHERE store_db=’$store’ LIMIT 1”, ‘account_id’));
    • while this does, using the same class and method:$data = $db->do_query(“SELECT account_id FROM reports WHERE store_db=’$store’ LIMIT 1”, ‘account_id’);
      list($account) = array_keys($data);
      // this also works:
      // $account = $data[0][‘account_id’];
    • Really, sometimes an extra line is worth not having the headache.

MVCFDH: One way to do MVC in PHP

August 28th, 2008 by sjan

Aaron Saray, over at 102Degrees, put up an interesting article today on MVCFDH, what he calls his way of building MVC architecture in PHP.

The short version is Model-View-Controller (which we are all familiar with) and adding the ‘Front Controller,’ ‘Dataobject’ and ‘Helper’ pieces. I won’t go into details here about what all this means, you can read it over there. The interesting thing is, without really having given it that kind of thought, that is pretty much the way I have always pieced together any kind of MVC work I have done, regardless of the language.

I think there might be a minor difference, though, at least in what we call things. I tend to think of them as ‘Dispatcher’ (don’t jump my case for calling it that, it works in my head!) rather than ‘Front Controller’, ‘Libs’ rather than ‘Helpers’ and ‘Dataobjects?’ I call them ‘Data Objects.’ :P

iPhone updated

August 24th, 2008 by sjan

I am a bit late in posting this, but things have been a bit hectic around here. However, I have finally update my iPhone, now that TouchTerm is available from the iTunes store. I tried using the tool from modmyiphone but had terrible results with it. Thankfully I had a backup of my firmware (1.1.4) before trying it and immediately went back to using that. Now that I am on the 2.0 bandwagon, however, I have wasted no time in amassing a bunch of tools that I use daily.

Some of my favorites:

  • TouchTerm, for ssh access to my servers. This was the big show-stopper prior to now. Worth it to me to pay for. (And cheap, too!)
  • Bookmarks for quick acess to my bookmarks. Massive time saver, and the layout is useful if a bit stark and utlitarian.
  • Palringo for chat. There have been some concerns voiced on the comments in the app store about security, and such. I’m not so worried about it. I have a password I use for chat and different ones for more important things like email and such. I don’t use chat (outside of the jabber at work, which is not in my Palringo account) for anything important.
  • TouchCalc for its hex and binary modes. There is an octal mode as well, but I haven’t had need of it (yet).
  • Stanza for reading books on my iPhone. I read a lot, and it is nice to have half-a-dozen books at hand. And with the desktop app I can convert just about anything I can get online into a readable book for the iPhone. Very nice.
  • Twinkle for keeping up with twitter.
  • Tankbuch for keeping track of mileage and gas usage. My Forrester gets an average of 23.2 MPG in the city, and 30.4 on the highway!
  • Zenbe Lists for my shopping lists. It means that my wife can update the list from her PC while I am on my way to the store and I can sync when I get there and see everything I need to pick up. It also means that I can sync after checking everything off and I don’t have to relay the entire list of what I was able or unable to find when I get home.
  • Lots of games. I like the free ones, partly because I am cheap, and partly because I don’t generally play a single game long enough to warrant paying for it. The exception is Sextuple Word Challenge – a word game very much like TextTwist. (I have a bit of an addiction to word games, and hey, it’s only a buck.)