Code

javascript function LeftRight()

To get a little jquery love happening, and since left() and right() don't outright exist in javascript, I crafted a little function to handle both. I like to call it "LeftRight".

function LeftRight(LR, str, n) {
  if (n <= 0) {
    return "";
  } else if (n > String(str).length) {
    return str;
  } else {
    var start="";
    var end="";
    if(LR=="L") {
      start=0;
      end=n;
    } else if (LR=="R") {
      start=String(str).length;
      end=start-n;
    }
    return String(str).substring(start,end);
  }
}

Usage:

if(LeftRight("L",selected.text(),6) == "WOWZAH") {
  $("#TheDivID").show();
}

CodeIgnitor + Prototype

I was at a PHP User Group meeting earlier this week where the presenter was extolling the virtues of the great Symfony MVC framework for PHP, which he started using last month. I've been experimenting with it for a few months longer and shared some of the same reactions when I first started a few experiments. I had to leave about thirty minutes in, and no doubt I missed some really hot PHP action, but there's another MVC I've been toying with recently, CodeIgnitor. Couple this with the javascript framework Prototype, and the possibilities are not just endless... they're really *^%&%$# fast.

That's my major complaint with untweaked Symfony projects - speed. CodeIgnitor, while it requires you to CODE a bit more (than in Symfony) to accomplish your (same) goals, is blazing. What Prototype gives you is a means by which you can get fast responses on the page (AJAX functionality). This, when you think about making on-screen updating of information *even faster* than conventional PHP, is an amazing concept.

Anyway, I'm working on something that I hope to Beta in a few weeks using this dynamic duo. It'll be a Web app that works well in mobile browsers, including BlackBerry devices complying with the RIM cHTML constraints. And it'll be smokin' fast.

Eclipse IDE

I downloaded eclipse last week for home (Mac) & work ("Other") use, and I'm really impressed so far. It hasn't blown me away like Visual Studio's runtime debugging does/can, but it's definitely much more streamlined than disparate dev+compile+run+debug scenarios do for Java and PHP. In fact, this is the first "real" IDE I've used for PHP, having relied on Notepad/Textedit and gEdit/Dreamweaver for all these years. Impressive. I'll spend more time running actual development scenarios before reviewing it in full here.

To SOA or not to SOA, that is the question.

As I just blogged, there are three kinds of people in this world when it comes to listening to music in cars. Similarly, there are three kinds of people when it comes to Service Oriented Architecture ("SOA") adoption:

  1. Conservative / Anti-
  2. Judicious
  3. Rampant(Don't you just love my even-handed labels??? :) )

Before I begin, I'd like to obviously throw myself out there as a #2. Yes, there are cases where SOA and Web services make a LOT of sense, more so than not. Nay-sayers are fooling themselves if they think this a passing fad. Any idea that has this kind of traction will in fact likely NOT go away. Not quietly, at least.

SOAStill, there are many developers who argue that developing as much as possible in original code as services - or the consumption of them - makes great sense for any application in any organization. I just don't see the point if the services don't connect or enable systems that aren't disparate or disconnected enough to merit it. And with that I'll focus my tirade of reasons to be rational about SOA on the #3's.

You should employ SOA if there:

  • will be multiple consumers (of a message or action)
  • is more than a single possible application of the service
  • are no more efficient methods available, balancing the above two points

And you should *consume* messages if:

  • the services already exist or
  • it makes sense (see above) to create the messaging services

Seriously, it's that simple. If you have two boxes in the same data center - using the same NAS - that need to access the same files... well, dude... path of least resistance. If you're dealing with those two servers plus eighteen other consumers at partner sites, then YES! Write it all now!!! What's that? You want to batch load data into an Oracle database for warehousing? DUDE: DROP INDICES, SQLLDR, RECREATE INDICES. No need for a web service to pick up the records. Maybe I'm missing the point entirely, and please do correct me if I'm missing some basic tenet that would make my position pure bunk, but I think the madness needs to stop.

[It's also worth pointing out that Web services, while cool and all, are just one tool in the belt of .NET 3.x with the advent of Windows Communication Foundation (WCF). Even more interesting is hearing MS guys forget that the architecture is a generic and platform-agnostic thing. You do not need any MS technology to just as easily implement Web services. I know, shocking. And the diagram above - minus the UDDI, of course, because who really uses UDDI?? - was like a revelation for one of these cats when I broke the news a month ago.]

There's a breaking point at which the shift in architecture makes sense. It happens to be a pretty low point, but STILL there are those out there who would have us adapting absolutely everything to SOA. Tomorrow, if possible. I don't know about you, but I'd rather dig my eyes out with a spoon than defend the really common-sense position against that. Good thing my floor is usually out of spoons.

Fibonacci across (programming) languages

Scott Hanselman has been writing an interesting series of posts reflecting on how coding patterns converge and diverge between languages. More precisely, he has been emphasizing how important it is to *read* code, consuming it as we would anything else. How else do you learn a "language", after all? And there are no Berlitz tapes for F#, trust me. Anyway, The Weekly Source Code 13 hits on how a Fibonacci number generator looks in a few languages.

This subject is particularly fascinating to me, and increasingly so as I run into / work with people who only know or use one or two languages or constructs. Context is everything, I think. Understanding the patterns and syntax of multiple languages can only help.