Digital Serenity

Digital Serenity is the blog of John McPherson Leask III (Jay). His mind wanders from food to travels, every-day activities and humor to sports, podcasting and technology - though mostly the focus of Digital Serenity will be his technological exploits.

May 2007 - Posts

Continuing on my series called the Javascript Library, I offer you more scripts that every web developer should have in their arsenal for every web project.

To start, how often does your project require you read items from a query string?  It isn't a best practice but if you only had things in your arsenal that were best practices you'd never be able to work with other developers.

For this script you'll need a script already in my Javascript Library, getSubString().  Once you have that in your project this one is a synch:

getQueryStringParam()
function getQueryStringParam(paramName)
{
  var qs = String(window.location);
  var paramValue = getSubString(qs, paramName +'=', '&');
  return paramValue;
}

That's right, 3 lines of code surrounded by the function wrapper, and only one input parameter:

  • paramName
    The name of the value you need from within your query string. 

Now that I've shown you how, I really have to warn you: DON'T PASS THINGS AROUND IN YOUR QUERY STRING.  Users have a tendency to do stupid things including typing randomly in query strings - if for some reason you have decided that this is the practice you want to do (or your boss insists it is) make sure you remember the following:

  • Encrypt your Query string (try Mads Kristnsen's HttpModule)
  • Build in error handling: your users WILL mess up the addresses and you don't want your code to puke on them
  • Never, I will repeat this, NEVER put the username and password in your query string, not even encrypted.  Amongst many other reasons, users who use public terminals will watch their password stolen over and over again.

Do you use the query string a lot?  Why (or even, why not)?

Posted by jleask | with no comments
Filed under: ,

A bit of humor to make your day pass smoothly - how do you make a project that is over budget, over time, and understaffed look good to upper management?

Quick answer - Fudge the dates associated with your work items, no one ever checks those:

Estimated Start Date: 1/17/2007
Start Date: 7/11/2006
Finish Date: 3/15/2006

 

Posted by jleask | with no comments
Filed under:

I'm not new to BizTalk but my experience is limited to mapping, lots and lots of mapping (if your Google search brought you here and you're looking for a Guru, sorry but I'm not him.  Go check out Stephen Thomas's BizTalkGurus.com site instead).  In fact I spent about 4 months using the BizTalk Mapping tool for BizTalk 06 before I was even a regular .NET programmer.  That said, I learned something new today: the BizTalk Advanced "Looping" functoid isn't required as often as I thouht it was.

What is the "Looping" Functoid?  I'm going to point you to the MSDN definition for details, but basicailly when you have multiple XML nodes in your sources schema and you need them to all loop into the same set of nodes in your destination schema, you use the looping functoid.

Considering this map, even though the two parents are differnt, they will both end up in the same repeating node in the destination, each with their own version of destionations <parent>.    Now this may not be a suprise to you, it's fairly self explainitory.  What does suprise me though is the following.  If I wasn't looking to map, from the souce, both <parent> and <parent2> into the same <parent> node in the destination, I wouldn't need the Looping functoid.

Instead I'd only need to drag a link between both of the <parent> nodes, as follows:

Now this really doesn't seem that major, in fact I don't believe it make your maps more effient or quicker, but what it does mean is less functoids on your map panels, and if you've worked with huge schemas, you know how difficult it can get to read your maps when they're full of tons of functoids (Check out Tim Rayburn's comments on Mapping Organzation for ways to keep your crazy maps in check!)

That said, not linking the parent in any way at all, like this:

... gives you a destination that will combign all of the children of every parent in the source into a single parent in the destination,  and at least in most of the cases I've worked with, this is not the desired effect. 

Looking back at it, this seems fairly obvious, but as they say, hind sight is 20/20 ... What seemingly obvious things have you picked up along the way that makes your Maps less complicated?

 

Posted by jleask | 1 comment(s)
Filed under:

Every web developer, even those in denial that they are such, should have a solid library of JavaScript functions that they can bring with them to every project. The reasons are many, but lets just start with the following two today:

  1. As Javascript is used in nearly every web-related project, you're bound to reuse this library over and over again.
  2. You have enough to code - don't waste your time redoing this every time you take on another project.

So today I offer you a simple custom Javascript to extend the use of the Javascript substring() method. Why the substring method? How often have you found yourself needing the middle of a string (can anyone say query string values?).

getSubString()
function getSubString(thestring, pointFrom, pointTo)
{
  if (pointFrom != null && pointFrom != '')
  {
    var start = thestring.indexOf(pointFrom) + pointFrom.length;
    var secondString = thestring.substring(start, thestring.length);
  } else {
    var secondString = thestring;
  }
  var end = secondString.indexOf(pointTo);
  if (pointTo != '' && end >= 0) {
    var finalString = secondString.substring(0, end);
  } else {
    var finalString = secondString;
  }
  return finalString;
}

As I've said, it's a fairly simple function. there are three parameters:

  • thestring
    The string you are looking to substring from.
  • pointFrom
    The starting point within your string; passing a null value will start your substring from the beginning.
  • pointTo
    The ending point within your string; passing a null value will use the end of the original string as your ending point.

This is the version I use, any suggestions?

Posted by jleask | with no comments
Filed under: ,